Skip to content
Search lessons, topics, tests…
Esc

    ↑ ↓ moveEnter openEsc close
    Cheat sheets: all cheat sheets

    What's New in .NET 11 and C# 15: What Interviewers Ask

    The C# 15 features (union types, closed hierarchies, collection expression arguments, extension indexers, labeled break and continue), Runtime Async and the new LINQ joins, each with a C# 14 example beside it and the answer to give in an interview.

    .NET 11 and C# 15 add new ways to model choices, write collections, and run async code. These examples prepare you to explain the changes in an interview.

    .NET 11 in 30 seconds

    .NET 11 was released on 10 Nov 2026. It is a standard-term support (STS) release. C# 15 adds union types, closed hierarchies, collection expression arguments, extension indexers, and labeled break and continue. The runtime (the part of .NET that runs your code) adds Runtime Async. LINQ adds FullJoin and overloads of Join and GroupJoin that do not need a result selector.

    Checked on 27 Nov 2026 against Microsoft's What's new in .NET 11 and What's new in C# 15 pages.

    Support means Microsoft ships security and bug fixes for that version. Long-term support (LTS) releases get at least three years of support; STS releases get two.

    The official starting points are What's new in .NET 11 and What's new in C# 15. Below, each language feature has a C# 14 example followed by its C# 15 replacement. Predict each program's output before running it.

    Union types: name a fixed set of alternatives

    A union type holds a value of exactly one of a fixed list of case types. For example, Pet can mean a Cat, a Dog, or a Bird.

    Before C# 15, you might group these types with a marker interface. A marker interface declares no operations; it only identifies types as belonging to a group. That does not tell the compiler that the group has no other members.

    C# 14, on .NET 10:

    C#Runs
    IPet[] pets = [new Cat("Milo"), new Dog("Rex"), new Bird("Pip")];
    foreach (var pet in pets)
    {
        Console.WriteLine(pet switch
        {
            Cat c => $"Cat: {c.Name}",
            Dog d => $"Dog: {d.Name}",
            Bird b => $"Bird: {b.Name}",
            _ => "Another pet"
        });
    }
    
    public interface IPet { }
    public sealed record Cat(string Name) : IPet;
    public sealed record Dog(string Name) : IPet;
    public sealed record Bird(string Name) : IPet;
    Output
    Cat: Milo
    Dog: Rex
    Bird: Pip

    Each branch of a switch expression, such as Cat c => ..., is called an arm. The _ => arm is the default arm: it catches any value that no other arm matched. Here, that fallback is needed because another class could implement IPet. In C# 15, the declaration itself names every alternative.

    C# 15, on .NET 11:

    C#
    Pet cat = new Cat("Milo");
    Pet dog = new Dog("Rex");
    Pet bird = new Bird("Pip");
    Pet[] pets = [cat, dog, bird];
    
    foreach (var pet in pets)
    {
        Console.WriteLine(pet switch
        {
            Cat c => $"Cat: {c.Name}",
            Dog d => $"Dog: {d.Name}",
            Bird b => $"Bird: {b.Name}"
        });
    }
    
    public union Pet(Cat, Dog, Bird);
    public sealed record Cat(string Name);
    public sealed record Dog(string Name);
    public sealed record Bird(string Name);
    Output
    Cat: Milo
    Dog: Rex
    Bird: Pip

    Needs .NET 11 (C# 15). Built and run with it: the output above is what the program really printed.

    A Pet value wraps its case value, such as a Cat; pet switch examines that wrapped value. Each assignment converts a case to Pet implicitly: you do not write a cast. The switch is exhaustive, meaning it handles every declared case, so it needs no default arm.

    Each of the three existing types converts to Pet, without inheriting from a shared base class.

    Use a union for success-or-error returns or a fixed set of messages. Prefer a base class or interface when you need shared behavior, rather than only a list of alternatives. See the union type reference.

    The mistake to avoid. Do not assume an empty interface closes the set of implementations. A union names that set and lets the compiler check switches against it.

    In an interview, say: “A union represents exactly one of a fixed set of case types. Each case converts to it implicitly. A switch can handle every case without a default arm. I would use one for result-or-error returns or closed message sets.”

    Closed hierarchies: restrict who can inherit

    An assembly is a compiled .NET library or executable, usually a .dll or .exe file. If a class is marked closed, only classes in the same assembly can derive directly from it.

    In C# 14, an abstract base class prevents direct construction, but does not restrict derivation to its assembly.

    C# 14, on .NET 10:

    C#Runs
    GateState state = new Open(75);
    Console.WriteLine(state switch
    {
        Closed => "closed",
        Open(var percent) => $"{percent}% open",
        _ => "another state"
    });
    
    public abstract record GateState;
    public sealed record Closed : GateState;
    public sealed record Open(float Percent) : GateState;
    Output
    75% open

    C# 15's closed modifier gives the compiler a known set of direct descendants. A direct descendant derives straight from GateState, not from one of its children.

    C# 15, on .NET 11:

    C#
    GateState state = new Open(75);
    Console.WriteLine(state switch
    {
        Closed => "closed",
        Open(var percent) => $"{percent}% open"
    });
    
    public closed record GateState;
    public sealed record Closed : GateState;
    public sealed record Open(float Percent) : GateState;
    Output
    75% open

    Needs .NET 11 (C# 15). Built and run with it: the output above is what the program really printed.

    In the second program, covering both direct descendants makes the switch exhaustive. A closed class is implicitly abstract: you cannot construct it directly.

    sealed means no class can derive from that class. closed permits derivation within the assembly. A union is different again: it groups types without requiring inheritance. Read the closed reference.

    The mistake to avoid. closed does not mean “only nested classes can derive from this.” The boundary is the declaring assembly, not the declaring class or file.

    In an interview, say: “A closed class is implicitly abstract and allows direct derivation only within its assembly. The compiler can check switches over its direct descendants. A sealed class allows no derivation, while a union groups alternatives without inheritance.”

    Collection expression arguments: configure the collection

    A collection expression is the bracket syntax used to create a collection, such as [1, 2]. Sometimes the items are not enough: you also need to configure the collection's constructor.

    Capacity is the number of elements a collection can hold before its internal storage must grow. A comparer supplies the rules for comparing values, such as ignoring letter case.

    C# 14, on .NET 10:

    C#Runs
    int[] values = [1, 2];
    var numbers = new List<int>(capacity: 10);
    numbers.AddRange(values);
    var tags = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
    {
        "a", "A"
    };
    
    Console.WriteLine($"Numbers: {numbers.Count}; capacity: {numbers.Capacity}");
    Console.WriteLine($"Unique tags: {tags.Count}");
    Output
    Numbers: 2; capacity: 10
    Unique tags: 1

    A HashSet<T> stores unique values. Here, its comparer treats "a" and "A" as equal, so only one tag remains.

    In C# 15, put with(...) first to pass constructor arguments. The .. values part inserts the elements from values.

    C# 15, on .NET 11:

    C#
    int[] values = [1, 2];
    List<int> numbers = [with(capacity: 10), .. values];
    HashSet<string> tags = [with(StringComparer.OrdinalIgnoreCase), "a", "A"];
    
    Console.WriteLine($"Numbers: {numbers.Count}; capacity: {numbers.Capacity}");
    Console.WriteLine($"Unique tags: {tags.Count}");
    Output
    Numbers: 2; capacity: 10
    Unique tags: 1

    Needs .NET 11 (C# 15). Built and run with it: the output above is what the program really printed.

    The constructor configuration changes; the intended contents do not. See collection expressions.

    The mistake to avoid. Capacity is not the number of items already in a list. Setting capacity to 10 does not create ten elements.

    In an interview, say: “In C# 15, the first collection-expression element can be with(...), which passes constructor arguments such as capacity or a comparer. Before that, I would call the constructor and then add the items.”

    Extension indexers: add bracket access

    An indexer lets an object support bracket access, such as point[0]. An extension indexer adds that syntax without changing the original type.

    An extension method is a static method whose first parameter is marked with this; you call it as if it belonged to that type. Before C# 15, an extension method could provide the operation, but callers used a method name rather than brackets.

    C# 14, on .NET 10:

    C#Runs
    var point = new Point(3, 7);
    Console.WriteLine(point.GetCoordinate(0));
    Console.WriteLine(point.GetCoordinate(1));
    
    public sealed record Point(int X, int Y);
    
    public static class PointExtensions
    {
        public static int GetCoordinate(this Point point, int index) => index switch
        {
            0 => point.X,
            1 => point.Y,
            _ => throw new ArgumentOutOfRangeException(nameof(index))
        };
    }
    Output
    3
    7

    C# 15 allows the indexer inside an extension block. An extension block groups added members for a receiver: the object those members operate on.

    C# 15, on .NET 11:

    C#
    var point = new Point(3, 7);
    Console.WriteLine(point[0]);
    Console.WriteLine(point[1]);
    
    public sealed record Point(int X, int Y);
    
    public static class PointExtensions
    {
        extension(Point point)
        {
            public int this[int index] => index switch
            {
                0 => point.X,
                1 => point.Y,
                _ => throw new ArgumentOutOfRangeException(nameof(index))
            };
        }
    }
    Output
    3
    7

    Needs .NET 11 (C# 15). Built and run with it: the output above is what the program really printed.

    The named receiver is point. Index 0 reads its X property, and index 1 reads Y. The C# 15 overview describes the named-receiver requirement.

    The mistake to avoid. Do not omit the receiver's name. An extension indexer is an instance member and needs a named receiver parameter.

    In an interview, say: “C# 15 lets an extension block declare an indexer, so callers can use bracket syntax without changing the receiver type. The block must provide a named receiver parameter.”

    Labeled break and continue: choose the outer loop

    Ordinary break exits the nearest loop. Ordinary continue starts its next iteration. Nested loops sometimes need to target an outer loop instead.

    In this example, a negative value skips the rest of its row. Zero ends the entire search.

    C# 14, on .NET 10:

    C#Runs
    int[][] rows = [[1, 2], [-1, 3], [4, 5], [0, 6], [7, 8]];
    bool stop = false;
    
    for (int row = 0; row < rows.Length && !stop; row++)
    {
        foreach (int value in rows[row])
        {
            if (value == 0)
            {
                stop = true;
                break;
            }
            if (value < 0)
                break;
            Console.WriteLine(value);
        }
    }
    Console.WriteLine("Finished");
    Output
    1
    2
    4
    5
    Finished

    The Boolean flag carries the stop decision from the inner loop to the outer loop. Breaking on a negative value reaches the end of the outer loop's body, so processing advances to the next row.

    C# 15 can name the outer loop directly.

    C# 15, on .NET 11:

    C#
    int[][] rows = [[1, 2], [-1, 3], [4, 5], [0, 6], [7, 8]];
    
    outer: foreach (var row in rows)
    {
        foreach (int value in row)
        {
            if (value == 0)
                break outer;
            if (value < 0)
                continue outer;
            Console.WriteLine(value);
        }
    }
    Console.WriteLine("Finished");
    Output
    1
    2
    4
    5
    Finished

    Needs .NET 11 (C# 15). Built and run with it: the output above is what the program really printed.

    continue outer; moves to the next row. break outer; leaves both loops.

    Before C# 15, other choices included goto or moving the loops into a method and returning. See jump statements.

    The mistake to avoid. An unlabeled break inside the inner loop does not leave both loops. Use the outer label when that is the intended destination.

    In an interview, say: “In C# 15, I can label the outer loop and write break outer; to leave it, or continue outer; to advance it. Before C# 15, I would use a flag, goto, or a separate method with return.”

    Runtime Async: the runtime tracks suspended methods

    An async method can pause at an await and resume later. Traditionally, the compiler generates a state machine: code that records where execution should resume and which values must survive the pause.

    Runtime Async moves that tracking into the runtime. Microsoft's runtime page describes cleaner stack traces, easier debugging, and lower overhead (less extra work and memory spent just to run async code). A stack trace shows the chain of method calls associated with execution or an error.

    For a project targeting net11.0, the runtime page shows this project-file setting:

    XML
    <PropertyGroup>
      <Features>runtime-async=on</Features>
    </PropertyGroup>

    A net11.0 project no longer needs <EnablePreviewFeatures>true</EnablePreviewFeatures> for Runtime Async. The .NET runtime libraries themselves are compiled with runtime-async=on and use runtime-provided async rather than compiler-generated state machines.

    The mistake to avoid. Do not turn “lower overhead” into a promised speedup for your application. The runtime page gives no universal performance number; measure your workload.

    In an interview, say: “Runtime Async lets the runtime track async suspension and resumption instead of compiler-generated state machines. It gives cleaner stack traces, easier debugging, and lower overhead. For net11.0, Microsoft's project setting is Features set to runtime-async=on; EnablePreviewFeatures is no longer required.”

    LINQ joins: keep unmatched values from both sides

    .NET 10 added LeftJoin and RightJoin, which preserve unmatched elements from the left or right sequence respectively. .NET 11 adds FullJoin, which preserves unmatched elements from both.

    When no match exists, the missing side supplies its type's default value. That is null for the record classes below, but zero for an int.

    .NET 11 also adds overloads without a result selector, the function that normally builds each output value. Join, LeftJoin, RightJoin and FullJoin then return tuples of the two matched values. GroupJoin returns groups instead: each group's Key is the outer element, and the group holds its matching inner elements.

    The first two foreach loops unpack each tuple into two variables.

    .NET 11:

    C#
    Product[] products = [new(1, "Laptop"), new(2, "Mouse")];
    Stock[] stocks = [new(1, 3), new(3, 7)];
    
    foreach (var (product, stock) in products.FullJoin(stocks, p => p.Id, s => s.ProductId))
        Console.WriteLine($"Full: {product?.Name ?? "no product"}, {stock?.Quantity.ToString() ?? "no stock"}");
    
    foreach (var (product, stock) in products.Join(stocks, p => p.Id, s => s.ProductId))
        Console.WriteLine($"Matched: {product.Name}, {stock.Quantity}");
    
    foreach (var group in products.GroupJoin(stocks, p => p.Id, s => s.ProductId))
        Console.WriteLine($"Group: {group.Key.Name}, stock entries: {group.Count()}");
    
    public sealed record Product(int Id, string Name);
    public sealed record Stock(int ProductId, int Quantity);
    Output
    Full: Laptop, 3
    Full: Mouse, no stock
    Full: no product, 7
    Matched: Laptop, 3
    Group: Laptop, stock entries: 1
    Group: Mouse, stock entries: 0

    Needs .NET 11. Built and run with it: the output above is what the program really printed.

    FullJoin keeps the matched laptop, the mouse without stock, and the stock entry without a product. Join keeps only the matched pair. GroupJoin gives one group for each product, and the mouse's group is empty.

    These additions are available on Enumerable, Queryable, and AsyncEnumerable; see the libraries page.

    The mistake to avoid. Do not treat a missing value as always being null. Joins use the missing side's default value, which depends on its type.

    In an interview, say: “.NET 10 added LeftJoin and RightJoin. .NET 11 adds FullJoin, which keeps elements from both sequences and supplies default values for missing matches. It also adds overloads without a result selector: Join and the outer joins return tuples, and GroupJoin returns groups keyed by the outer element.”

    EqualityComparer.Create: compare by a selected key

    An equality comparer defines when two values count as equal. Sometimes two objects should count as the same because one property matches, even when their other properties differ.

    .NET 11 adds an EqualityComparer<T>.Create overload that takes a key selector: a function that chooses the value used for comparison.

    .NET 11:

    C#
    var byEmail = EqualityComparer<Customer>.Create(customer => customer?.Email);
    var first = new Customer(1, "sam@example.com");
    var second = new Customer(2, "sam@example.com");
    var customers = new HashSet<Customer>(byEmail) { first, second };
    
    Console.WriteLine($"Equal by email: {byEmail.Equals(first, second)}");
    Console.WriteLine($"Unique customers: {customers.Count}");
    
    public sealed record Customer(int Id, string Email);
    Output
    Equal by email: True
    Unique customers: 1

    Needs .NET 11. Built and run with it: the output above is what the program really printed.

    The selector can receive null, so it uses customer?.Email. The IDs differ, but the selected email values match. The comparer therefore reports equality, and the set keeps one customer. This avoids writing a separate comparer class for this key-based rule.

    The mistake to avoid. The comparer does not change the record's own equality rules everywhere. You must pass it to the operation or collection that should use it.

    In an interview, say: “EqualityComparer<T>.Create can build a comparer from a key selector. I can compare customers by email, for example, and pass that comparer to a set without writing a separate comparer class.”

    Trying .NET 11 and deciding whether to move

    Install the .NET 11 SDK beside .NET 10. The SDK contains the tools used to build your project. Test in a separate branch before changing a production service.

    For the support dates of each version, see .NET Versions and Support Dates.

    Set the project's target framework (the .NET version it builds against) to <TargetFramework>net11.0</TargetFramework>. The default language version follows the project's target framework; see language version configuration.

    The memory safety feature adds rules for code that uses unsafe to access memory directly. A preview feature is not finished; you turn it on by setting <LangVersion>preview</LangVersion> in the project file. Preview features may change and are not for production. The updated memory safety rules also need updated-memory-safety-rules, a feature flag that enables those specific compiler rules.

    LTS releases get at least three years of support and STS releases get two. Because .NET 11 ships one year after .NET 10, both reach end of support at about the same time. So the real trade-off is new features against the work and risk of upgrading twice: to .NET 11 now, then to the next LTS. See Microsoft's support policy.

    Before moving a service:

    1. Read the .NET 11 breaking changes, including changes affecting the deployment environment.
    2. Update the target framework and compatible package versions.
    3. Run the tests and check the service's important workloads before deployment.

    The mistake to avoid. “Newer” does not automatically mean “the right upgrade now.” A service can reasonably remain on .NET 10 LTS when .NET 11 brings no worthwhile benefit.

    In an interview, say: “.NET 11 is STS with 24 months of support; .NET 10 is LTS with 36 months. Both end support around November 2028. I would upgrade only for a needed feature, then review breaking changes, target net11.0, update packages, and run tests. To try preview language features, I set LangVersion to preview in the project file, not in production.”

    Check yourself

    Which statement best distinguishes a union from a closed class?

    A A union requires every case to inherit from a common base class.
    B A union groups case types without inheritance; a closed class restricts direct derivation to its assembly.
    C A closed class cannot have derived classes.
    D Both allow direct derivation from any assembly.
    Show answer

    Correct answer: B

    A union names alternatives. A closed class uses inheritance but limits where its direct descendants can be declared. A sealed class prevents derivation entirely.

    A FullJoin uses record classes on both sides. What happens to an element with no matching key on the other side?

    A It is discarded.
    B It is kept, with null for the missing side.
    C It causes an exception.
    D It is converted into an empty record.
    Show answer

    Correct answer: B

    FullJoin preserves unmatched elements from either sequence. The missing side supplies its default value, which is null for a record class.

    In C# 15, outer: labels the outer of two nested loops. What does continue outer; do inside the inner loop?

    A It leaves both loops.
    B It starts the next iteration of the outer loop.
    C It starts the next iteration of the inner loop.
    D It jumps back to the start of the program.
    Show answer

    Correct answer: B

    A labeled continue starts the next iteration of the loop the label names. break outer; would leave both loops, and an unlabeled continue only advances the inner loop.

    Going deeper

    Union defaults need care. A default-initialized union can contain null, even when every case type is nonnullable. Compiler nullability analysis tracks where null might occur, but it does not prevent null contents at runtime. An exhaustive case-type switch can still throw SwitchExpressionException for a default union. Handle null when default contents can reach the switch; the union reference explains the distinction.

    Closed inheritance is not automatically closed at every level. A non-closed descendant can still have descendants in another assembly. Mark intermediate descendants closed when you need exhaustiveness checking further down. You cannot combine closed with sealed, static, or an explicit abstract modifier.

    Join comparison is configurable. The selector-free Join and GroupJoin overloads accept an optional equality comparer; comparer overloads are also available for FullJoin, LeftJoin, and RightJoin.

    Other library additions on the libraries page include:

    • Zstandard compression, supporting the Zstandard compression format.
    • JSON Lines support in System.Text.Json, for JSON values separated by newlines.
    • The numeric types Decimal32, Decimal64, and Decimal128.
    • Process helpers for working with running programs.
    • Async DataAnnotations validation; DataAnnotations uses attributes to describe validation rules.

    C# 15 also permits non-virtual static interface members (static members that implementations do not override) on older runtimes without default interface implementation support.

    ASP.NET Core 11 and EF Core 11 have their own What's new pages, linked from the .NET 11 overview.

    Sources

    TechInterviewNotes Editorial Team · Updated 27 Nov 2026 ·