c#: what is a constant expression?

前端 未结 4 681
半阙折子戏
半阙折子戏 2021-01-18 11:30

I\'m working with attributes at the moment. I often run into the error \'An attribute argument must be a constant expression, typeof expression or array creation expression

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-18 12:22

    Attributes in C# are compile time artifacts, so in order to be created they have to have a constant type parameters/markers/whatever...

    There are possible attempts to do what you are, I suppose, going to do:

    Dynamic Attributes in C#

提交回复
热议问题