VaR type inference keyword. It can automatically infer the type of the variable after the value assignment, but can only be used for local variables. It cannot be used for class member definitions and parameter passing.
An anonymous class, that is, a class cannot be defined, which is automatically generated by the system. The following Code creates an anonymous real-column SSZ, and the system automatically defines the name, age, height, job and other field members. This definition is similar to the list <t> generic initializer.
Static void main (string [] ARGs) {var SSZ = new {name = "Shi shaozhuang", age = 38, Height = 35, job = ""}; console. writeline (SSZ. name); console. writeline (SSZ. age); console. writeline (SSZ. height); console. writeline (SSZ. job); console. readkey ();
}
VaR keyword and Anonymous class (from www. sysoft. CC)