Baj*_*k80 0 c# generics system.reflection
我有一个属性类(继承属性),在其中我有一个调用泛型方法的方法:
memberInfo.GetCustomAttribute<T>();
Run Code Online (Sandbox Code Playgroud)
如何将当前类类型传递给T?我不想在内部硬类型,因为它可能被继承,然后它将无法工作.
您可以使用所采用的版本Type,而不是通用版本:
memberInfo.GetCustomAttribute(this.GetType());
Run Code Online (Sandbox Code Playgroud)