Get value from custom attribute-decorated property?

后端 未结 2 1281
无人及你
无人及你 2021-02-13 20:05

I\'ve written a custom attribute that I use on certain members of a class:

public class Dummy
{
    [MyAttribute]
    public string Foo { get; set; }

    [MyAtt         


        
2条回答
  •  攒了一身酷
    2021-02-13 21:00

    You get array of PropertyInfo using .GetProperties() and call PropertyInfo.GetValue Method on each

    Call it this way:

    var value = prop.GetValue(o, null);
    

提交回复
热议问题