Skip to content
Discussion options

You must be logged in to vote

null-coalescing assignment is a candidate for C# 8.0, so

public IList<int> Numbers 
{
    set; get => field ??= new List<int>();
}

and if the property type is the same as the instance get => field ??= new(); should work too.

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants
Converted from issue

This discussion was converted from issue #2001 on October 19, 2020 11:15.