# Language rules

Code style language rules affect how various constructs of .NET programming languages, for example, modifiers and parentheses, are used. The rules fall into the following categories:

• .NET style rules: Rules that apply to both C# and Visual Basic. The EditorConfig option names for these rules start with dotnet_style_ prefix.
• C# style rules: Rules that are specific to C# language only. The EditorConfig option names for these rules start with csharp_style_ prefix.
• Visual Basic style rules: Rules that are specific to Visual Bsic language only. The EditorConfig option names for these rules start with visual_basic_style_ prefix.

## Option format

Options for language rules can be specified in an EditorConfig file with the following format:

option_name = value:severity

• Value: For each language rule, you specify a value that defines if or when to prefer the style. Many rules accept a value of true (prefer this style) or false (do not prefer this style). Other rules accept values such as when_on_single_line or never.
• Severity: The second part of the rule specifies the severity level for the rule. Severity specification as part of the above option syntax is only respected inside development IDEs, such as Visual Studio. This setting is not understood by the C# or VB compilers, hence not respected during build. Instead, to enforce code style rules on build, you should set the severity by using the rule ID-based severity configuration syntax for analyzers. The syntax takes the form dotnet_diagnostic.<rule ID>.severity = <severity>, for example, dotnet_diagnostic.IDE0040.severity = silent. For more information, see this GitHub issue.

Tip

Starting in Visual Studio 2019 version 16.3, you can configure code style rules from the Quick Actions light bulb menu after a style violation occurs. For more information, see Automatically configure code styles in Visual Studio.

## .NET style rules

The style rules in this section are applicable to both C# and Visual Basic.

## C# style rules

The style rules in this section are applicable to C# language only.

## Visual Basic style rules

The style rules in this section are applicable to Visual Basic language only.