ReSharper for Visual Studio Code 2026.1 Help

Code Syntax Style: Default Value Expressions ('default' vs 'default(T)')

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.

Therefore, ReSharper provides two code style preferences for default value expressions:

  • when the type is evident from usage (for example, in parameter declarations or field initializations),

  • when the type is not evident (for example, in method call arguments or return statements).

ReSharper helps you enforce style preferences for default value expressions in the existing code and takes your preferences into account when it produces new code with code completion and performs refactorings.

Enforce preferences for default value expressions

By default, ReSharper highlights type specifications as redundant and helps remove them:

ReSharper syntax style inspection: Use 'default' literal

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.

Configure preferences for default value expressions

You can configure syntax style settings via EditorConfig. These settings can be stored in .editorconfig files on different levels of your solution hierarchy. The files are normally put under VCS so that settings defined there are shared among the project team.

If you have used ReSharper for Visual Studio or JetBrains Rider on your computer, or have opened the current solution using these tools, ReSharper for Visual Studio Code will read and apply your syntax style settings from .DotSettings files. However, any settings configured via .editorconfig will take precedence.

Configure preferences for default value style using EditorConfig

  1. Open the desired .editorconfig file.

  2. Add the required default value style properties to the file. For example:

    default_value_when_type_evident = default_expression
03 March 2026