← All notes

C# records: value equality, with-expressions, positional syntax

Short answer

A record is a reference type built for data. Two records of the same type with the same values compare equal. Use with for a copy that changes selected properties. [S1]

Sketch

public record Person(string First, string Last);
var p2 = p1 with { Last = "Smith" };

Points

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

Source notice: .NET documentation © Microsoft. Licensed under Creative Commons Attribution 4.0 International (https://github.com/dotnet/docs/blob/main/LICENSE).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn, Records (C# reference), CC BY 4.0 (dotnet/docs); Microsoft Learn, Create record types in C#, CC BY 4.0 (dotnet/docs).

Cite this

Permanent ID: iil:note:00qak38e

iinventedlight. 2026. "C# records: value equality, with-expressions, positional syntax." iinventedlight Library, iil:note:00qak38e, version of 2026-11-04. https://iinventedlight.com/library/notes/csharp-records/. License: CC-BY-4.0.

@misc{iil_note_00qak38e,
  author = {{iinventedlight}},
  title = {{C\# records: value equality, with-expressions, positional syntax}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/csharp-records/},
  note = {Permanent ID iil:note:00qak38e. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/csharp-records.md.