.NET Core 1.1
支持 Type.GetInterfaces()
方法,该方法提供在给定类型上实现的接口(interface)列表。遗憾的是,Type.GetInterfaces()
在 .NET Standard 1.x
中尚不可用。
好消息是它应该包含在 .NET Standard 2.0
中。
与此同时,有没有人知道我可以用来获取类型的接口(interface)列表和/或在 .NET Standard 1.x
中实现给定接口(interface)的类列表的变通方法>?
非常感谢!
最佳答案
这应该可以解决问题。 GetTypeInfo()
是 System.Reflection
命名空间中的扩展方法,是 InstrospectionExtensions
的一部分。
using System.Reflection;
var interfaces = typeof({SOME_TYPE}).GetTypeInfo().GetInterfaces();
关于c# - .NET Standard 1.x 的 Type.GetInterfaces() 解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44191048/