All rules
IDE0008Language rules ('var' preferences)

Use explicit type instead of var

Use explicit type instead of var

Microsoft docs
Documented together with IDE0007Use var

Description

These two style rules define whether the var keyword or an explicit type should be used in a variable declaration. To enforce that var is used, set the severity of IDE0007 to warning or error. To enforce that the explicit type is used, set the severity of IDE0008 to warning or error.

Example

// csharp_style_var_for_built_in_types = true
var x = 5;

// csharp_style_var_for_built_in_types = false
int x = 5;

Configurable options

Vote for the value each option should take in the generated .editorconfig.

csharp_style_var_for_built_in_types
default: false
csharp_style_var_when_type_is_apparent
default: false
csharp_style_var_elsewhere
default: false
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0