Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Records described as "immutable by default" when they are not #21224

Closed
jbogard opened this issue Oct 26, 2020 · 1 comment · Fixed by #21562
Closed

Records described as "immutable by default" when they are not #21224

jbogard opened this issue Oct 26, 2020 · 1 comment · Fixed by #21562
Assignees
Labels
🏁 Release: .NET 5 Work items for the .NET 5 release doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-csharp/svc whats-new/subsvc

Comments

@jbogard
Copy link

jbogard commented Oct 26, 2020

Only certain usages of the record syntax provide "immutable by default". However, it is possible (and quite easy) to create a mutable record type:

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

var person = new Person { FirstName = "Jimmy", LastName = "Bogard" };
person.LastName = "Fallon";

This all compiles and runs.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@BillWagner BillWagner added 🗃️ Technology - C# What's New 🏁 Release: .NET 5 Work items for the .NET 5 release doc-bug Problem with the content; needs to be fixed [org][type][category] and removed ⌚ Not Triaged Not triaged labels Oct 27, 2020
@BillWagner
Copy link
Member

Thanks @jbogard

As I add more tutorial content on records, more of the examples will reinforce your point. I'll update this in the same way before the release.

@BillWagner BillWagner added this to To do in November 2020 via automation Oct 27, 2020
@BillWagner BillWagner added this to To do in .NET Languages (.NET 5 wave) via automation Oct 27, 2020
@BillWagner BillWagner self-assigned this Nov 4, 2020
@BillWagner BillWagner moved this from To do to In progress in November 2020 Nov 13, 2020
.NET Languages (.NET 5 wave) automation moved this from To do to Done Nov 16, 2020
November 2020 automation moved this from In progress to Done Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏁 Release: .NET 5 Work items for the .NET 5 release doc-bug Problem with the content; needs to be fixed [org][type][category] dotnet-csharp/svc whats-new/subsvc
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants