-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add reason for using primary constructor #50741
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ dev_langs: | |
|
|
||
| This rule flags classes that can use a [primary constructor](../../../csharp/programming-guide/classes-and-structs/instance-constructors.md#primary-constructors) instead of a separate constructor definition. You define a primary constructor by placing any constructor parameters in parentheses following the type name. A primary constructor indicates that these parameters are necessary for any instance of the type. | ||
|
|
||
| The ability of a class or struct in C# to have more than one constructor provides for generality, but at the expense of some tedium in the declaration syntax, because the constructor input and the class state need to be cleanly separated. Primary constructors put the parameters of one constructor in scope for the whole class or struct to be used for initialization or directly as object state. The trade-off is that any other constructors must call through the primary constructor. | ||
|
||
|
|
||
| ## Options | ||
|
|
||
| Options specify the behavior that you want the rule to enforce. For information about configuring options, see [Option format](language-rules.md#option-format). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The paragraph uses passive voice ("provides for generality") and complex phrasing that doesn't follow the conversational, active voice style required by the documentation guidelines. The text should be rewritten in active voice with simpler, more direct language. Consider rephrasing to use "you" and present tense with a conversational tone.