如何确定接口类型是否实现自定义属性

mku*_*kus 0 c# reflection attributes

如何确定接口类型是否实现自定义属性?

Sam*_*eff 5

用途GetCustomAttributes:

typeof(IWhatever).GetCustomAttributes(typeof(CustomAttribute), false)
Run Code Online (Sandbox Code Playgroud)

将返回一组属性.如果它没有实现您正在搜索的那个,则为空.