1

想象一个简单的属性类。该属性已用于属性。
属性类可以“看到”它的应用吗?

[AttributeUsage(AttributeTargets.Property)]
public class MyPropAttr : Attribute {
    public MyPropAttr () {
        PropName = ????; // default I was applied to prop X
    }
    public string SomeAttribute { get; set; }
    public string PropName { get; set; }   //<<<<<<<<< can this be determined ???
}

public class MyClass{
  [MyPropAttr(SomeAttribute="Bla")] 
  public string SomeFancyProp{ get; set; }
}
4

0 回答 0