I read on a blog that C# 7 will feature record types
class studentInfo(string StudentFName, string StudentMName, string StudentLName);
However
C#9 is now available and records with it.
Here are some example:
public record Person
{
public string LastName { get; init; }
public string FirstName { get; init; }
public Person(string first, string last) => (FirstName, LastName) = (first, last);
}
With the use of positional records (and inheritance):
public record Teacher(string FirstName, string LastName,
string Subject)
: Person(FirstName, LastName);
public sealed record Student(string FirstName,
string LastName, int Level)
: Person(FirstName, LastName);
var person = new Person("Bill", "Wagner");
var (first, last) = person;
Console.WriteLine(first);
Console.WriteLine(last);
Finally, records support with-expressions. A with-expression instructs the compiler to create a copy of a record, but with specified properties modified:
Person brother = person with { FirstName = "Paul" };
Everything you need to know about every new features including records here