Why can't we add a lambda as attribute parameter? For example I would like to do:
[MyAttribut(Transform= {object => object.ToSomethingElse()})]
Should I understand that lambda in C# are only closure?
EDIT: By looking at all answer let me precise one things that most people seems to not know: Lambda are literal whish is a compile time structure unless it is a closure.
Parameters to attributes need to be compile time constants.
From MSDN - Attribute Parameter Types:
Values passed to attributes must be known to the compiler at compile time.
They are also restricted to these types:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With