|
|
|
|
|
by louthy
3953 days ago
|
|
The 'cool but funky' thing is LINQ. Language Integrated Query. It can be used to query in-memory lists and arrays as well as build SQL to query a DB, or even query XML files. It is C#'s support for monads. In terms of var. It's best not to think of it as dynamic like javascript. You can't do this for example: var a = 123;
a = "Hello";
The second line will throw an exception because 'a' is not a string, it's an int. So it's not dynamic like JS. It simply infers the type when it can so that you don't have to type it, otherwise its exactly the same.Interestingly C# does have a dynamic aspect too, and that's with the 'dynamic' keyword. dynamic x = 123;
x = "Hello";
That will work where the var example wouldn't. It's a rarely used feature, but comes in useful to avoid boilerplate when dealing with external 'stuff', like XML files, JSON, or REST responses. |
|