How we Implicitly Typed Local Variables in C Sharp 3.0
| In C# 3.0 we have new keyword called "var".Var helps us to declare a new variable, which is implicitly inferred from the expression whic is used to initialize the variable here is the syntax:-
var i = 1; In last line we initializes a variable i to value 1 and gives its type integer.We strongly type "i" to an integer.It is not an object or a VB6 variant,and it is not carry the overhead of an object or a variant.The var keyword allows you to refer t |
|
| o instances of anonymous types (described in the next section) and yet the instances are statically typed. So, when you create instances of a class that contain an arbitrary set of data, you don't need to predefine a class to both hold that structure and be able to hold that data in a statically typed variable. | |
