<1> the anonymous type provides a convenient method to encapsulate a set of read-only attributes into a single object without explicitly defining a type. The type name is generated by the compiler and cannot be used at the source code level. The type of each attribute is inferred by the compiler.
Example:
Public Curry {public string Age; public string Name; public string Sex ;}// initialization object Curry curry = new Curry {Age = "18", Name = "Andeson ", sex = "femal"}; // or uses the Anonymous class var curry = new {Age = "18", Name = "Andeson", Sex = "femal "};
We can see that new is not followed by the class type, so we define an anonymous class. We don't need to know the name of this class. We can only read this attribute and cannot rewrite the attribute value.
Var Cur = new {m = 100, n = "sdsdfr"}; // Cur. m = 1000; // error, cannot be assigned because it is read-only.
<2> An anonymous class is a class derived directly from an Object.
There is no difference between the anonymous type and other reference types. The only difference is that the anonymous type can only be forcibly converted to the Object type.
<3> if two or more anonymous types have the same number of attribute types in the same dataset, the compiler treats these anonymous types as the same type in the same sequence. They share the type information generated by the same compiler.