This commit is contained in:
SoulliesOfficial
2025-12-13 23:28:23 -05:00
parent 40660b41e0
commit 467e385991
49 changed files with 238 additions and 161 deletions

View File

@@ -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--;
}
}
}