The Var Keyword- Implicitly Typed Local Variables

The var keyword has been introduced to C# 3.0. When the compiler encounters a var keyword, it implicitly initialize the variable to the type of the initialization expression. For example, if the compiler sees var s = "dummy string" it converts it to string s = "dummy string".

Therefore, an implicitly typed variable must be initialized. For example,
var s
is not a legal declaration.

The var keyword can not be used as a function parameter


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: