[C#] Anonymous Type


[C#] Anonymous Type

무명형식입니다. 어떤 객체가 다시 재사용될 일은 없는데, 클래스나 구조체를 만들지않고 쓰려고 할때 anonymous type을 사용합니다. Colored By Color Scripter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace anonymous_type_test { class Program { static void Main(string[] args) { var a = new {name = "abc", age = 20}; Console.WriteLine(a.name + " " + a.age); //a.name = "test"; //error, 무명형식은 할당 후 변경불가. } } } 무명형식은 할당 후에 값을 변경...


#IT·컴퓨터

원문링크 : [C#] Anonymous Type