Interviews2 answers
What is Implicit typed variable (var) in c#?
2 Answers
initialize variable at compile time
eg:
var x = 100;
Mahesh Kumar AlankaPosted Sep 18, 2014, 10:45 AM EDT
Implicit typed variable type (var), this feature has been added from c# 3.0 which allows to declare a variable using "var" keyword. The type of the variable is identified at the time of its compilation depending upon the value assigned to it.
Eg-
var a=99; // a is int type (at compile time)
var s="Hi"; // s is string type(at compile time)
var f=1.23 ; // f is float type(at compile time)
Satheesh Kumar PilliPosted Aug 20, 2014, 10:08 AM EDT

