如何连接两个IEnumerable的< T>进入一个新的IEnumerable< T>?两个、IEnumerable、GT、LT

2023-09-02 21:54:24 作者:来到这世上没打算活着回去

我有的IEnumerable与其中的两个实例; T> (具有相同 T )。我想的IEnumerable℃的新实例; T> 这是双方的串联

I have two instances of IEnumerable<T> (with the same T). I want a new instance of IEnumerable<T> which is the concatenation of both.

有没有在.net中一个内置的方法,这样做或做我必须写我自己?

Is there a build-in method in .Net to do that or do I have to write it myself?

推荐答案

是,LINQ到对象支持这一带的 Enumerable.Concat

Yes, LINQ to Objects supports this with Enumerable.Concat:

var together = first.Concat(second);