From a4111b074d76d538f4cc140a1313dcf0e7f331ae Mon Sep 17 00:00:00 2001 From: YaKun9 Date: Thu, 18 Jul 2024 17:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=BA=A0=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SageTools/Extension/Collection.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/SageTools/Extension/Collection.cs b/SageTools/Extension/Collection.cs index a914979..eda06fc 100644 --- a/SageTools/Extension/Collection.cs +++ b/SageTools/Extension/Collection.cs @@ -118,16 +118,20 @@ public static void PagingToOperate(this ICollection list, Action /// 集合中元素的类型。 /// 要操作的集合。 - /// 要对集合中的每个元素执行的操作。操作接受集合和当前元素的索引作为参数。 - public static void ForEach(this ICollection list, Action, int> action) + /// + /// 要对集合中的每个元素执行的操作。操作接受两个参数: + /// 第一个参数是当前元素的索引(int),第二个参数是当前元素(T)。 + /// + public static void ForEach(this IList list, Action action) { if (list.IsNullOrEmpty()) { return; } + for (var i = 0; i < list.Count; i++) { - action(list, i); + action(i, list[i]); } } }