如果查询返回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);