Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

507
Views
How to declare a C# Record Type?

I read on a blog that C# 7 will feature record types

class studentInfo(string StudentFName, string StudentMName, string StudentLName);

However when I tried it, I get these errors

CS0116 A namespace cannot directly contain members such as fields or methods
CS1022 Type or namespace definition, or end-of-file expected
CS1514 { expected

How is this supposed to work?

Update: it's a feature of C# 9 https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Update:

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:

https://github.com/dotnet/csharplang/blob/master/proposals/records.md

Discuss or vote at https://github.com/dotnet/csharplang/issues/39

about 4 years ago · Santiago Trujillo Report

0

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."

about 4 years ago · Santiago Trujillo Report

0

[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.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!