Programming paths / C#

C# learning path

Use modern C# to build maintainable services, desktop tools, and cross-platform applications.

Starter lesson

Represent application state with a record

A record is useful for data whose identity is defined by its values. Immutable-style data makes updates and comparisons easier to reason about.

using System;
using System.Collections.Generic;
using System.Linq;

public record Job(string Title, bool IsReady);

class Program
{
    static void Main()
    {
        var jobs = new List<Job>
        {
            new("Build API", true),
            new("Write tests", false)
        };

        var readyJobs = jobs.Where(job => job.IsReady);
        foreach (var job in readyJobs)
        {
            Console.WriteLine(job.Title);
        }
    }
}

What to expect

Build API

Key idea: Choose data structures that communicate intent, and keep mutable state limited to places that need it.

← Browse all programming paths