Immutable Order Record
Records make value-based models concise and safe to copy.
How it works
Update immutable data with a with expression.
The original record is preserved while the copy receives a different status.
Runnable C# example
Program.cs
using System;
record Order(int Id, string Status);
class Program
{
static void Main()
{
var pending = new Order(7, "Pending");
var shipped = pending with { Status = "Shipped" };
Console.WriteLine($"{pending.Status} -> {shipped.Status}");
}
}
Pending -> ShippedPractice 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.