C# 10 Record Structs: Optimization

C# 9 Records were reference types (classes). C# 10 brings Record Structs.

public readonly record struct Point(int X, int Y);

This gives you:
1. Value semantics (stack allocation).
2. Immutability.
3. `ToString()` printing content.
4. Zero allocation!

Use this for high-frequency types like GEO coordinates, financial ticks, or composite keys.


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.