The simple answer is because that's how Microsoft introduced the var keyword in the specification for .NET 3.0.
Why is implicit typing disallowed in non-local variable declarations? [duplicate]
-
22-09-2022 - |
سؤال
I changed this:
List<string> chapterNames = new List<string>();
...to this:
var chapterNames = new List<string>();
...and was jabbed with this message from the compiler:
"The contextual keyword 'var' may only appear within a local variable declaration"
المحلول
لا تنتمي إلى StackOverflow