且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

测试对象是否实现任何泛型类型的通用接口

更新时间:2022-12-04 17:39:59

如何像

return type.GetInterfaces()
           .Where(t => t.IsGenericType)
           .Select(t => t.GetGenericTypeDefinition())
           .Any(t => t.Equals(typeof(IDictionary<,>)));



我敢肯定,你可以很容易地概括为任何泛型类型定义。

which I'm sure that you can easily generalize for any generic type definition.