Code inspection: Use preferred style of default value expression when type is not evident
When you evaluate a default value of a type with the default value expression, and the type can be inferred, you can use either the default(T)
operator or the default
expression.
In other words, type specification (T)
is optional with default
when the type can be inferred.
Depending on the context, the optional type specification can either clutter your code with redundant information or, on the contrary, improve the readability.
By default, ReSharper highlights type specifications as redundant and helps remove them:
If you prefer to have explicit type specifications in your code, you can change the corresponding preferences and ReSharper will help you add missing type specifications:
For more information about configuring and enforcing your preferences for default value expressions, refer to Code Syntax Style: Default Value Expressions ('default' vs 'default(T)').