The .NET languages enable you to create an object that does not have a class representation at design time. Instead, an unnamed (anonymous) class is created for you by the compiler. This feature is called anonymous types. Anonymous types provide crucial support for LINQ queries. With them, columns of data returned from a query can be represented as objects (more on this later). Anonymous types are compiled into class objects with read-only properties.
Let’s look at an example of how you would create an anonymous type. Suppose that you want to create an object that has both a
Name and a
PhoneNumber property. However, you do not have such a class definition in your code. You could create an anonymous ...