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);

Related Contents

15 May 2014, 08:07 AM
C#, LINQ, List
15 May 2014, 07:54 AM
C#, LINQ, List
29 Apr 2014, 03:07 AM
C#, Generic
About
Explains how to create Anonyous object in c#

Date Posted 12 Mar 2014, 09:10 AM
Author Brainy Solutions
Views 1,050
;