如何连接两个IEnumerable的< T>进入一个新的IEnumerable< T>? [英] How to concatenate two IEnumerable<T> into a new IEnumerable<T>?

查看:159
本文介绍了如何连接两个IEnumerable的< T>进入一个新的IEnumerable< T>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有的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);

这篇关于如何连接两个IEnumerable的&LT; T&GT;进入一个新的IEnumerable&LT; T&GT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆