public static void ForLoop <T>(this IList <T> src, EventHandler <ForEachArgs <int> > excuteFunction) { if (src == null || src.Count <= 0) { return; } for (int i = 0; i < src.Count; i++) { if (excuteFunction != null) { var e = new ForEachArgs <int>(i); excuteFunction(src, e); if (e.Cancel) { break; } } } }
/// <summary> /// 使用ForEach循环 /// </summary> /// <typeparam name="T">循环类型</typeparam> /// <param name="src"></param> /// <param name="excuteFunction"></param> public static void ForEachLoop <T>(this IList <T> src, EventHandler <ForEachArgs <T> > excuteFunction) { if (src == null || src.Count <= 0) { return; } foreach (T item in src) { if (excuteFunction != null) { var e = new ForEachArgs <T>(item); excuteFunction(src, e); if (e.Cancel) { break; } } } }