Records

  • can be class or struct
  • creates methods overrides for enforcing value equality instead of reference equality:
    • Object.Equals
    • Object.GetHashCode
    • operators
      • ==
      • !=
  • implements IEquatable<> parameter
  • implements ToString
  • supports deconstruction
  • supports with expression
  • meant to be immutable

Positional records is a more concise syntax for record:

  • primary constructor parameters match the positional parameters of the record declaration
  • public init-only properties for each parameter

Further read:

https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/records#characteristics-of-records

One Reply to “Records”

Leave a Reply

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

Solve : *
21 + 30 =