【发布时间】:2011-06-09 21:16:58
【问题描述】:
假设我有以下代码:
List<SomeObject> someObjects = ReturnListWithThousandsOfObjects();
foreach(SomeObject someobject in someObjects)
{
DoSomething.With(someObject);
}
还假设在运行一分钟后我在DoSomething.With(someObject); 上设置了一个断点。
调试器对我来说很好。但现在我想知道我在列表迭代中处于什么位置(假设列表无序/没有键)。
有没有办法让调试器说“foreach 已经运行了 2321 次迭代中的 532 次”?
【问题讨论】:
-
这个问题和this one很像,请看my answer there
-
规范问题是 How do you get the index of the current iteration of a foreach loop?(但可能还有其他调试器技巧)。