结构体的 with 表达式

版本新特性 / C# 10.0

using System;

var p1 = new Point(5, 5);
var p2 = p1 with { X = 10 };
//p2 is (10, 5)

Console.WriteLine($"p2 is ({p2.X}, {p2.Y})");

struct Point {
    public int X, Y;

    public Point(int x, int y) {
        X = x;
        Y = y;
    }
}