Type inference makes use of the var
keyword. The compiler "infers" what the type of the variable is by what the variable is initialized to.
e.g. var somenum=o;
becomes int somenum=0;
Even though somenum is never declared as being an int
, the compiler figures this out & somenum is an int
for as long as it is in scope.
it is like variant
type used in visual basic
. using it in program, upto some extent it degrades performance & var
is not included in dot net framework before 3.5 .
even it degrades performance & dot net framework supports strong type checking ,why var
is included in framework 3.5?
is var
violets strong type checking? if not how?