This page looks best with JavaScript enabled

Getting Started with LINQ in C#

 ·   ·  ☕ 1 min read

    LINQ can be confusing and some of the ways it works may not be intuitive if you’re unfamiliar with them. Let’s take a look at writing some basic LINQ queries and dissect how they work.

    We’ll discuss how LINQ queries are evaluated and some of the results of lazy evaluation. In addition we will look at building our own infinite list in C# using the yield command.

    We’ll explore a few different queries and some common commands you can use while writing them to avoid having to implement the functions yourself including how to transform objects using Select, filter objects using Where and collect results using functions like Min, Max and Sum. To prevent infinitely looping when evaluating our infinite list we will also take advantage of the Skip and Take commands to skip over N elements and take N elements from a list respectively.

    Microsoft has published their own intro to LINQ. You can find it here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/introduction-to-linq-queries

    There is more information here as well: https://msdn.microsoft.com/en-us/library/bb308959.aspx

    The World of Zero Discord channel: https://discord.gg/hU5Kq2u


    Sam Wronski
    WRITTEN BY
    Sam Wronski
    Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!