作为我学徒的一部分,我必须找到一种方法来(自动)搜索嵌套超过 4 层的语句。
我使用 Visual Studio (2012) 和 C# 编程语言。
(错误)嵌套方法的示例。
foreach (int i in items) //1
{
Console.WriteLine(i);
foreach (int a in items2) //2
{
Console.Write(a);
foreach (int b in items3) //3
{
Console.Write(b);
foreach (int c in items4) //4
{
Console.Write(c);
foreach (int d in items5) //5
{
// Here an error/warning should be shown because it is nested too deep
Console.Write(d);
foreach (int e in items5)
{
Console.Write(e);
}
}
}
}
}
}
我曾尝试使用 ReSharper(7.1),但这并没有(据我所知)提供此功能。
我怎样才能做到这一点?