繁体   English   中英

LINQ IEnumerable <T[]> 到IEnumerable <T>

[英]LINQ IEnumerable<T[]> to IEnumerable<T>

如果查询返回IEnumerable,如何使它变平并使所有T都在单个IEnumerable中?

var types = from genericType in subscriber.GetType().GetInterfaces()
            where genericType.IsGenericType 
            && genericType.GetGenericTypeDefinition() == typeof (ISubscriber<>)
            select genericType.GetGenericArguments();

您可以从Linq使用SelectMany方法:

var flat = types.SelectMany(x => x);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM