字段上的C#属性

时间:2008-10-01 05:07:43

标签: .net custom-attributes

如何在程序集中的任何位置设置属性,然后在整个程序集中反映这些字段属性并获取/设置属性附加的字段值?

1 个答案:

答案 0 :(得分:22)

1)创建custom attribute的目标fields 2)Add it to desired fields
3)迭代types defined in your assembly
4)每个type
4a)iterate through it's fields
4b)如果字段has your custom attribute转到步骤4c
4c)字段的getset