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 guess I'm looking for a sanity check here...
public delegate bool Bar(string s); [AttributeUsage(AttributeTargets.All)] public class Foo : Attribute { public readonly Bar bar; public Foo(Bar bar) { this.bar = bar; } } public class Usage { [Foo(b => b == "Hello World!")] // IntelliSense Complains here public Usage() { } }
Yes this is correct. Attribute values are limited to constants of the following types
Reference: http://msdn.microsoft.com/en-us/library/aa288454(VS.71).aspx
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