Thursday, September 13, 2007

Var Keyword in C# - .Net 3.5 Orcas Feature

In .Net 3.5 Orcas consist of a keyword called var. This keyword can be used to reference any type in c#. For example,

var name = "raja";
var age = 26;
var single = true;

The compiler will infer the type of the "name", "age" and "single" variables based on the type of their initial assignment value

string name = "raja";
int age = 26;
bool single = true;

No comments: