Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use
This applies to:
- C#
What: Use new()
.
When: You have a field that can't use var
or a code style preference to not use var
.
Why: So you don't have to write repetitive code by repeating the type twice.
How-to
Place your caret on the field declaration.
Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
Select Use 'new(…)':