Skip to main content

Empty switch statement

In This Article

CodeRush Classic shows the Empty switch statement code issue if a switch statement is empty.

#Fix

Remove the empty switch statement.

#Purpose

Empty switch statement directs your attention to empty switch statements, which can be removed to improve your code readability.

#Example

public string MakeText(params string[] data)
{switch (data[0])
    {

    }
    string result = data[0];
    for (int i = 1; i < data.Length; i++)
        result += Environment.NewLine + data[i];
    return result;
}

Fix:

public string MakeText(params string[] data)
{
    string result = data[0];
    for (int i = 1; i < data.Length; i++)
        result += Environment.NewLine + data[i];
    return result;
}