How to Create Anonymous object in C#
12 Mar 2014, 09:18 AM
.Net provides an easy way to create anonymous type object using new operator with the object initializer. Following is the example to create anonymous type object in C#.
var user = new { Id = 1, Name = "Anonymous user", Salary = 3000 }; // get data from anonymous type and write on console Console.WriteLine(user.Id + " " + user.Name);