Attributes in C#

前端 未结 8 749
时光说笑
时光说笑 2020-11-30 04:08

I know that C# (and .NET in general) is big on attributes. However, despite the fact I have programmed in C# for many years, I haven\'t found myself ever using them. Would s

8条回答
  •  难免孤独
    2020-11-30 04:19

    I believe you mean that you do not use (or frequently use) custom defined attributes ?

    In my current project, I make heavy use of custom attributes, but, the fact that you need to keep in the back of your mind, is that using attributes should not be a goal on itself.

    It is a tool / purpose to get to a given solution.

    I sometimes use custom attributes in combination with a weaver like PostSharp, to decorate methods where some weaving should be applied to at compile-time.

    In my current project, I also use attributes to decorate certain types with additional info ... But I believe I've posted about this here before: Cool uses of Attributes or Annotations (CLR or Java)?

提交回复
热议问题