Performance overhead of using attributes in .NET

前端 未结 2 764
野的像风
野的像风 2020-12-30 06:37

1.. Is there any performance overhead caused by the usage of attributes? Think for a class like:

    public class MyClass
    {
       int Count {get;set;}
          


        
2条回答
  •  时光取名叫无心
    2020-12-30 07:06

    Jon Skeet is absolute right and I only want to give one additional notion:

    If you have a look at the base class of all attributes, System.Attribute, you'll notice, that most of its members are static. So they exist only once, no matter how many Attribute instances you have.

    This is just another point to underline, that Attributes are not too costly...

提交回复
热议问题