ReSharper 2024.1 Help

Code Inspection: Use preferred 'var' style (for built-in types)

Category

Syntax Style

ID

SuggestVarOrType_BuiltInTypes

EditorConfig

resharper_suggest_var_or_type_built_in_types_highlighting

Default severity

Hint

Language

C#

Requires SWA

No

This code inspection checks violations of your preferences for using var or explicit type in local variable declarations. Specifically, it checks variable declarations of C# built-in types (bool, double, string, etc.).

Using implicitly typed local variables (also known as var keyword) introduced in C# 3.0 has become quite popular as it improves readability in many scenarios. By default, ReSharper also encourages using of var keyword, but preferences of its usage are flexibly configurable — for example, you can opt for using explicit types in specific cases or everywhere and ReSharper will help you enforce your preferences.

For more information about configuring and enforcing your preferences of using var or explicit types in local variable declarations, refer to Code Syntax Style: Implicit/Explicit Typing ('var' Keyword).

Last modified: 15 April 2024