C# Method Attribute cannot contain a Lambda Expression?

后端 未结 1 1142
忘了有多久
忘了有多久 2020-12-09 09:00

IntelliSense is telling me \"Expression cannot contain anonymous methods or lambda expressions.\" Really? I was not aware of this imposed limitation. Is this correct? I gues

相关标签:
1条回答
  • 2020-12-09 09:32

    Yes this is correct. Attribute values are limited to constants of the following types

    • Simple types (bool, byte, char, short, int, long, float, and double)
    • string
    • System.Type
    • enums
    • object (The argument to an attribute parameter of type object must be a constant value of one of the above types.)
    • One-dimensional arrays of any of the above types

    Reference: http://msdn.microsoft.com/en-us/library/aa288454(VS.71).aspx

    0 讨论(0)
提交回复
热议问题