I'm getting this error,
An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
When I try to write something like this
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class UrlAttribute : Attribute
{
public UrlAttribute(string pattern, string name=null)
{
// ...
It doesn't even show a line number, but it disappears when I take out that =null
bit.
Actually, the error only occurs both when I provide a default value and rely on it (i.e., I omit it) like so
[Url("/index")]
I'm curious to know why this? How is "null" not a constant expression?