C# Attributes On Fields

后端 未结 1 1397
无人共我
无人共我 2020-12-30 07:05

How do I set an attribute on a field anywhere in my assembly, then reflect on those field attributes in my entire assembly and get/set the field values that the attribute is

相关标签:
1条回答
  • 2020-12-30 07:16

    1) Create custom attribute targeted for fields
    2) Add it to desired fields
    3) Iterate through types defined in your assembly
    4) For each type:
    4a) iterate through it's fields
    4b) if field has your custom attribute go to step 4c
    4c) get or set values of field

    0 讨论(0)
提交回复
热议问题