General information
Category:
Coding, syntax and commands
>>I thought they originally didn't want 'var'. Doesn't it go against the C# design principle of strong typing?
>>
>
>Not at all. It's still strongly-typed. It's just that now the compiler and Intellisense is smart enough to infer the type based on the return type. When you use var you aren't saying "I don't won't know it's type until later", but instead, "Hey, compiler, figure out the correct type for me". "var" was actually necessary to allow for anonymous types, which was necessary for LINQ. It's kind of interesting if you look at the language elements added to 3.5 how many of them were required in order to get LINQ working.
The whole language is still fascinating to me. I know I will be discovering tidbits about it for years to come.
Do you have a suggestion for the next thread in my little C# series? How about generics?
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only