限制可以使用 C# 自定义属性的位置

Limit where C# custom attribute can be used

我正在创建一个我只想在接口上指定的属性。在 C# 中有什么方法可以做到这一点吗?

 [AttributeUsage(AttributeTargets.Interface)]
 public class MyAttribute : Attribute
 {
 }

You have more options