How to get name of property which our attribute is set?

后端 未结 3 648
小鲜肉
小鲜肉 2020-12-15 03:34

I\'m going to do this without passing any parameter to attribute! Is it possible?

class MyAtt : Attribute {
    string NameOfSettedProperty() {
        //How         


        
3条回答
  •  既然无缘
    2020-12-15 03:50

    you can't do it within the attribute class itself. however, you can have a method that takes an object gets a list of that object's properties (if any) that use the attribute. use this API to implement that: http://msdn.microsoft.com/en-us/library/ms130869.aspx

提交回复
热议问题