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();
}
C# 14 · Basics
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();
}
Was this page helpful?