Professional Documents
Culture Documents
Usage rules/restrictions
The properties in Anonymous types are all read only and therefore cannot be modified
once they are created.
Anonymous types cannot have methods.
Anonymous types are always assigned to vars. This allows the compiler to assign the
right type. But, if Anonymous types are used as return values or as parameters in a
function, they will have to be passed in as Objects, as var is not a proper type
class Employee
{
private int _EmpID;
private string _EmpName;
public int EmpID
{
get { return _EmpID;}
set { _EmpID = value;}
}
public string EmpName
{
get { return _EmpName;}
set {_EmpName = value;}
}
}
1
The Visual Studio will provide us the full intellisense support for the anonymous type along
with the compile time checking.