Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/fundamentals/code-analysis/style-rules/ide0290.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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.
When you create a class or struct with multiple constructors, you gain flexibility, but you also add verbose syntax. You must cleanly separate the constructor input from the class state. With primary constructors, you can put one constructor's parameters in scope for the whole class or struct. You can use these parameters for initialization or directly as object state. However, if you add other constructors, they must call through the primary constructor.

## Options

Expand Down