Update
This commit is contained in:
@@ -10,12 +10,20 @@ namespace SLSFramework.General
|
||||
{
|
||||
/// <summary>
|
||||
/// 对列表中的每个元素执行指定的操作
|
||||
/// 可以处理在迭代过程中移除元素的情况
|
||||
/// </summary>
|
||||
public static void For<T>(this IList<T> list, System.Action<T> action)
|
||||
public static void For<T>(this IList<T> list, Action<T> action)
|
||||
{
|
||||
for (var index = 0; index < list.Count; index++)
|
||||
{
|
||||
int initialCount = list.Count;
|
||||
|
||||
action(list[index]);
|
||||
|
||||
if (list.Count < initialCount)
|
||||
{
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user