Why var is used before linq query
Why var is used before linq query
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Neha AdmecPosted Feb 5, 2022, 7:56 AM
Manoj BhoirPosted Jul 18, 2015, 1:53 AM
Rajeesh MenothPosted Jul 18, 2015, 1:38 AM
Govinda Rajulu YemineniPosted Jul 18, 2015, 1:23 AM
Isha MalhotraPosted Jul 10, 2015, 1:47 AM
Sakthikumar ThanavelPosted Jun 24, 2015, 3:21 PM
Jignesh TrivediPosted Mar 16, 2015, 12:12 AM
Hi,
This is not necessary.....
The var keyword was introduced in C# 3.0. It is an implicit type and the type is determined by the C# compiler. There is no performance penalty when using var. The C# compiler assigns types to the variable when it assigns the value.
It makes programs shorter and easier to read. In short the var keyword is an implicit way of defining data types. It is an indirect way of defining the variable type. The "var" keyword defines the data type statically (at compile time) and not at runtime.
also some time we use it with LINQ and anonymous types that help us reduce the code (reduce effort to create a new class).
hope this will help you.
Afzaal Ahmad ZeeshanPosted Mar 15, 2015, 9:57 AM