-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
dotnet-csharp/svcfundamentals/subsvchelp wantedGood for community contributors to help [up-for-grabs]Good for community contributors to help [up-for-grabs]
Description
I believe the article on Object and Collection Initializers should mention the init accessor as well as required modifier.
Specifically, it should be explained how these keywords enable advanced control over initializations, similar to how this section on Object Initializers with collection read-only property initialization does.
In brief:
init:
- like a ctor param, but also enabling usage of object initializers;
- another take: like a
setaccessor, but only during construction/init time, thus preventing mutability post-creation.
requried:
- like
init, but also must be set in object initializer, thus preventing only partially constructed objects (and precludes usage in ctor unless[SetsRequiredMembers]is used).
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 0efd6a6a-b52a-f6a2-d98b-f245b55115ff
- Version Independent ID: 95025282-20a0-ded8-c6d2-3b8ffff600c4
- Content: Object and Collection Initializers - C# Programming Guide
- Content Source: docs/csharp/programming-guide/classes-and-structs/object-and-collection-initializers.md
- Product: dotnet-csharp
- Technology: csharp-fundamentals
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn
Metadata
Metadata
Assignees
Labels
dotnet-csharp/svcfundamentals/subsvchelp wantedGood for community contributors to help [up-for-grabs]Good for community contributors to help [up-for-grabs]