Concatenate multiple IEnumerable

前端 未结 4 1392
鱼传尺愫
鱼传尺愫 2021-01-07 18:11

I\'m trying to implement a method to concatenate multiple Lists e.g.

List l1 = new List { \"1\", \"2\" };
List

        
4条回答
  •  一向
    一向 (楼主)
    2021-01-07 19:04

    If you want to make your function work you need an array of IEnumerable:

    public static IEnumerable Concartenate(params IEnumerable[] List)
    {
        var Temp = List.First();
        for (int i = 1; i < List.Count(); i++)
        {
            Temp = Enumerable.Concat(Temp, List.ElementAt(i));
        }
        return Temp;
    }
    

提交回复
热议问题