.NET Attributes: Why does GetCustomAttributes() make a new attribute instance every time?

前端 未结 3 1280
再見小時候
再見小時候 2020-12-04 01:34

So I was playing around a little more with attributes in .NET, and realized that every call to Type.GetCustomAttributes() creates a new instance of my attribute. Why is that

3条回答
  •  独厮守ぢ
    2020-12-04 02:11

    It's because the attributes are saved in metadata. Attributes should be used for informations such as "user-friendly name of property", etc...

提交回复
热议问题