LANGUAGE

readonly struct

Restricts mutation of the struct instance; referenced objects can remain mutable.

Formal Syntax & Structure

csharp syntaxcsharp
readonly struct Name { /* members */ }

Working Example

Example Snippetcsharp
readonly struct Distance { public int Meters { get; } public Distance(int meters) => Meters = meters; }
C# & .NET Reference