{Beginner C# samples} - What is the use of ‘var’ keyword in C# ?

Note: These beginner C sharp samples codes are written keeping the beginner in mind so the code is made as simple as possible.

Starting from C# 3.0 the “var” keyword is included. var is used when you want to declare a variable’s type implicitly instead of explicit.

Explicit declaration:

string s = “Great”;

Implicit declaration:

var s = “Great”;

In compile time the datatype is determined implicitly by the compiler.

Will explain more about this in the LINQ series later.

Bookmark / Share

Write your comment..




biuquote
  • Comment
  • Preview
Loading