C# 14 · Basics

Write a local function

Define a helper inside a method, where only that method can use it.

int Total(int[] items)
{
    return Sum(items);
    static int Sum(int[] xs) => xs.Sum();
}

Official C# 14 documentation

More basics commands

All basics commands · C# 14 cheatsheet

Was this page helpful?