C# language feature:
-
Implicitly typed local variables
applies to
- anonymous types, local variable declarations
benefit
- Allows a placeholder for anonymous types, which are often used in query expressions. Additionally, allows simplified declaration of local variables.
how to use
- Use the
var
contextual keyword (instead of a type specifier).
note
- Use of
var
does not hinder type safety. It allows convienient delaration of variables.
example: