Skip to content
Justice Tech School

Records

record gives value equality, ToString and with expressions for immutable data.

Example
var a = new Point(1, 2);
var b = a with { Y = 5 };
Console.WriteLine(a);
Console.WriteLine(a == new Point(1, 2));
Console.WriteLine(b);

record Point(int X, int Y);

Exercise

Copy with a change.

a  { Y = 5 }

Quiz Test

How does == work for records?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.