Use new()
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(…)':
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for