Browse Source

CollectionUtility:增加 Join 方法,将多个集合的元素连接为单个集合。

master
王厅 1 month ago
parent
commit
a686dd3b19
  1. 24
      Apewer/CollectionUtility.cs

24
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
}
}

Loading…
Cancel
Save