Anonymous types enable you to create objects without writing a class definition for the data type. Instead, the compiler generates a class for you. The class has no usable name and contains the properties you specify in declaring the object.

To create an instance of an anonymous type:

// sampleObject is an instance of a simple anonymous type.  
var sampleObject =
new { FirstProperty = "A", SecondProperty = "B" };
Last modified: March 20, 2019



Write a Reply or Comment