How to declare a C# Record Type?


C# 9 now contains record types.

public record Person
    public string LastName { get; }
    public string FirstName { get; }

    public Person(string first, string last) => (FirstName, LastName) = (first, last);

Old answer:

Record types are not (yet) implemented in C#. See the proposal in the official GitHub repository:

Discuss or vote at

Record types were on the roadmap for C# 7.0, but were ultimately delayed until a later version of the language.

To quote Mads Torgersen in reply to this blog post,

[Primary constructors] are still on the radar, along with the related concept of record types (which we considered for C# 7.0), and I am hopeful that we can land on a better design – maybe one that encompasses both.

As of C# 7's release, the GitHub proposal for this language feature still indicates that the implementation is "In Progress."

[Rewritten to reflect the current state of things]

To add to the other answers, you can easily track when C# features are pencilled in to appear in C# these days. For example, the Champion "Records" issue shows the state of thinking around records. Records is now scheduled for C# 9. But that feature was previously touted for C# 6, C# 7 and C# 8 too, so it remains only an aspiration.