Skip to content
Discussion options

You must be logged in to vote

As of next week, with the release of .NET 8 and C# 12, you will be able to use primary constructors to express that as:

public class Car(string brand, string model, string color, decimal price)
{
    public string Brand { get; set; } = brand;
    public string Model { get; set; } = model;
    public string Color { get; set; } = color;
    public decimal Price { get; set; } = price;
}

If you have concerns over this feature, such as the ability to use Json attributes, or you'd prefer to eg be able to express that as:

public class Car(
    string Brand { get; set; },
    string Model { get; set; },
    string Color { get; set; },
    decimal Price { get; set; })

Then head over to #7667 and r…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@serhiisolodovnyk
Comment options

Answer selected by serhiisolodovnyk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants