Another set of keywords useful in the LINQ language is the Let and Into keywords.
Monthly Archives: June 2016
LINQ Grouping Examples
Grouping is another powerful tool in the LINQ library. This gives you the ability to group data in specific ways. Take a look at the example by clicking more below.
Anonymous Types In LINQ
One really cool thing with C# .NET LINQ is the ability to take a query and output the data to an anonymous types. This work with either type of query be it comprehension or method syntax. The one drawback is that you can’t access this directly because it inherits directly from object. You would need to cast it as new defined type (class) to do this. You will see me doing this different ways thru the upcoming examples. How you choose to do it is based on your own personal preferences.
Type Inference Examples
Ahh type inferece. If you do any searching around stacktrace, code project, slashdot, etc.., you will find plenty of arguments for using strong typed variables or using the var keyword when declaring local variables. I’ve recently been using var keyword more in my code after reading C# In-Depth by Jon Skeet. The C# compiler does a good job if making sure things are safe at compile time. For example var stringList = new List<string>() is the same as List<string> stringList = new List<string>(). So it all comes down to personal preference when using C# .NET.