Remove unreachable code (IDE0035)

Property Value
Rule ID IDE0035
Title Remove unreachable code
Category Style
Subcategory Unnecessary code rules
Applicable languages C# and Visual Basic

Overview

This rule flags unreachable executable code within methods and properties that can never be reached, and hence can be removed. This rule has no associated code style option.

Example

// Code with violations
void M()
{
    throw new System.Exception();

    // IDE0035: Remove unreachable code
    int v = 0;
}

// Fixed code
void M()
{
    throw new System.Exception();
}

See also