This keyword can be used efficiently in following stages.
1. While assigning variable to values.
string firstName = "Aditya";
string lastName = "Acharya";
var name = firstName+lastName;
Response.Write(name);
object mark1 = 50;
object mark2 = 60;
var total = (int)mark1 + (int)mark2;
Response.Write(total);
2. While looping through:
string[] arrSubject = { "Physics", "English", "ComputerScience" };
foreach (var subject in arrSubject)
{
Response.Write(subject);
}
3. While declaring a Collection:
var total = 0;
var arrSubject = new [] { "Physics", "English", "ComputerScience" };
var arrMark = new[] { 60, 70, 80 };
foreach (var mark in arrMark)
{
total = total + mark;
}
(N.B This keyword can also be used for Visual Basic language. And usage of this keyword can be more, Here it is some of the examples out of many)