If a query returns IEnumerable, how can I make it flat and have all the T from the arrays in a single 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.