C# の基礎

Methods, Parameters, and Tuples

Methods group behavior behind a clear contract. Tuples are convenient for returning a small set of related values.

How it works

Define reusable methods with named results and multiple return values.

Named tuple elements make the returned values self-documenting without requiring a dedicated class.

Runnable C# example

C#
Run code →
Program.cs
using System;
using System.Linq;

class Program
{
    static (int Min, int Max) Range(int[] values)
        => (values.Min(), values.Max());

    static void Main()
    {
        var range = Range(new[] { 8, 3, 14, 5 });
        Console.WriteLine($"{range.Min}..{range.Max}");
    }
}
Expected output
3..14

Practice with the debugger

Set a breakpoint on an important assignment or condition, click Debug, and inspect the local values before stepping to the next line.