Let And Into LINQ Examples

Another set of keywords useful in the LINQ language is the Let and Into keywords.

Continue reading

Advertisements

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.

Continue reading

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.

Continue reading