1.调用
var aaa = new List<string>() { "0" };
var a1 = new List<string>() { "1" };
var a2 = new List<string>() { "2" };
var a3 = new List<string>() { "3" };
var a4 = new List<string>() { "4" };
var a5 = new List<string>() { "5" };
var b = aaa.MyConcat(a1, a2, a3, a4, a5);
int count = b.Count();
2.方法
public static class Test
{
public static IEnumerable<TSource> MyConcat<TSource>(
this IEnumerable<TSource> thisEnumerable,
IEnumerable<TSource> one,
IEnumerable<TSource> two,
IEnumerable<TSource> three,
IEnumerable<TSource> four,
IEnumerable<TSource> five)
{
foreach (var item in thisEnumerable) yield return item;
foreach (var item in one) yield return item;
foreach (var item in two) yield return item;
foreach (var item in three) yield return item;
foreach (var item in four) yield return item;
foreach (var item in five) yield return item;
}
}
举例
3.结果