Nested switch statements can affect code readability, refactoring and can cause additional bugs to creep in. Therefore, it is recommended that you refactor your code accordingly, i.e., either avoid nested switch
es or move the inner switch
to a separate method/lambda.
switch (outerValue)
{
case someValue:
switch (innerValue)
{
case 3.14:
Console.WriteLine("pi");
break;
// Additional cases
}
break;
}
Func<X, Y> someLambda ...
switch (outerValue)
{
case someValue:
someLambda(innerValue);
break;
}