rbwhitaker / CSharpPlayersGuideEarlyAccess

A place to track issues with the C# Player's Guide for patches and future editions
19 stars 0 forks source link

`required` members #643

Closed rbwhitaker closed 1 year ago

rbwhitaker commented 2 years ago

In C# 11, you'll be able to put the required keyword on properties (and fields? and other things?). This will indicate that it may not be initialized via constructor, but that the compiler does not need to warn you about not assigning a non-null value to it, because that will be done (and enforced) in object-initializer syntax.

Mads made it clear that this isn't meant to replace constructors, just trying to make object-initializer syntax easier to work with.

rbwhitaker commented 1 year ago

This has been added.