From a686dd3b19cdf972dabc3b9219ea07ed11a719fc Mon Sep 17 00:00:00 2001 From: Elivo <elivo@me.com> Date: Thu, 24 Apr 2025 13:53:21 +0800 Subject: [PATCH] =?UTF-8?q?CollectionUtility=EF=BC=9A=E5=A2=9E=E5=8A=A0=20?= =?UTF-8?q?Join=20=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B0=86=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E9=9B=86=E5=90=88=E7=9A=84=E5=85=83=E7=B4=A0=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E4=B8=BA=E5=8D=95=E4=B8=AA=E9=9B=86=E5=90=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer/CollectionUtility.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Apewer/CollectionUtility.cs b/Apewer/CollectionUtility.cs index 2d6c59d..7ad3b93 100644 --- a/Apewer/CollectionUtility.cs +++ b/Apewer/CollectionUtility.cs @@ -952,6 +952,30 @@ namespace Apewer #endregion + #region Join + + /// <summary>连接多个集合的元素为单个集合。</summary> + public static T[] Join<T>(params IEnumerable<T>[] collections) + { + if (collections == null) return new T[0]; + + var count = collections.Length; + if (count < 1) return new T[0]; + + var result = new List<T>(); + foreach (var collection in collections) + { + if (collection == null) continue; + foreach (var item in collection) + { + result.Add(item); + } + } + return result.ToArray(); + } + + #endregion + } }