C# is a marvelous language. It’s powerful, fast, and easy to learn. It also exposes advanced features that make doing otherwise difficult things simple. Even more impressively, it manages to make reading the code to do those complicated things easy, too. Many programming languages struggle with this last part. You might be able to do something really cool, but the code is opaque for other developers to read.
One example of a feature where C# makes the difficult easy is in the Language Integrated Natural Query (LINQ) interface. If you’ve been working with a C# code base for a little while, you might have run up against some LINQ code. The first time you see it can feel a little confusing. Some variations of LINQ code look like an entirely different programming language from the C# that you’re used to. Even for variations of LINQ that aren’t entirely different syntax, it can be difficult to parse just what the code you’re looking at is doing.
In this post, we’ll walk through the basics of LINQ and talk about how they work, so the next time you see some LINQ code, it’ll be because you’re writing it yourself.