When to use var or IEnumerable to store query result in LINQ?
Answer / Mohd Kasim Khan
Use var when you don't need the specific type of the collection. The compiler will infer the correct type based on the query results. Use IEnumerable when you want to explicitly specify that the collection is an IEnumerable and can be iterated.
| Is This Answer Correct ? | 0 Yes | 0 No |
How to write LINQ query for Inner Join with and condition?
How to use distinct in linq query?
What is meant by linq in c#?
what is the role of DataContext classes in LINQ?
What is linq in c# with example?
Explain what are linq compiled queries?
What is first in linq?
What do you understand by linq? Enlist its types.
How to pass parameters to stored procedure using linq?
List out the three main components of linq? Explain what is the extension of the file, when linq to sql is used?
How to write linq query in javascript?
Write the basic syntax of a LINQ query in Visual Basic as well as in C#.
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)