What is var?

 Posted by Sumank on 5/15/2013 | Category: LINQ Interview questions | Views: 3911 | Points: 40

Var is used to declare implicitly typed local variable means it tells compiler to figure out the type of the variable at compile time.
Since, 'var' is anonymous type, hence it is used where we don't know the type of output like joining of two tables.

var q = (from e in tblEmployee
join d in tblDepartment
on e.DeptID equals d.DeptID
select new
e.EmpID, e.FirstName, d.DeptName

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response