C#idiomatic C#
ide2000fundamentals/code-analysis/style-rules

Code analysis

Avoid multiple blank lines (IDE2000)

Learn about code analysis rule IDE2000: Avoid multiple blank lines

IDE2000 Style / Language rules (new-line preferences)
Applicable languages C# and Visual BasicOptions dotnet_style_allow_multiple_blank_lines_experimental

Overview

This style rule flags the presence of multiple consecutive blank lines in source code. Having multiple blank lines can reduce code readability and is generally considered poor formatting practice.

Options

Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.

dotnet_style_allow_multiple_blank_lines_experimental

Property Value Description
Option name dotnet_style_allow_multiple_blank_lines_experimental
Option values true Allow multiple consecutive blank lines
false Don't allow consecutive blank lines
Default option value true

Example

csharp
// dotnet_style_allow_multiple_blank_lines_experimental = true
if (true)
{
    DoWork();
}


return;
csharp
// dotnet_style_allow_multiple_blank_lines_experimental = false
if (true)
{
    DoWork();
}

return;

Suppress a warning

If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.

csharp
#pragma warning disable IDE2000
// The code that's violating the rule is on this line.
#pragma warning restore IDE2000

To disable the rule for a file, folder, or project, set its severity to none in the configuration file.

ini
[*.{cs,vb}]
dotnet_diagnostic.IDE2000.severity = none

To disable all of the code-style rules, set the severity for the category Style to none in the configuration file.

ini
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none

For more information, see How to suppress code analysis warnings.

See also