Instead of explicitly declaring the variable of a particular type (int, short, string etc), one can define a variable of type ‘var’ and allowing the compiler to infer the type
For example,
var i = 10;
is equivalent to
int i = 10;
The inferred type may be a built-in type, an anonymous type, a user-defined type, a type defined in the .NET Framework class library, or any expression.
No comments:
Post a Comment