T
ThisBytes5
I am using an attribute on the properties of my object to help with
parsing of data. The attribute will determine if the current property
is to be populated based on the version of the data. As such I need to
be able to create the attribute with the version and some other values
for the version. So I tried the following (typed for the example, not
the actual code).
defined the constructor for the Attrib as:
public MyAttrib(params object[] versions)
and defined the class as:
public MyClass
{
private string prop1;
[MyAttribute(new VersionInfo("1.0", "Description"), new
VersionInfo("2.0", "Description"))]
public string Prop1
{
get { return prop1; }
set { prop1 = value; }
}
}
The class fails to compile with the follwoing error:
An attribute argument must be a constant expression, typeof
expression or array creation expression
Have I defined something incorrectly? Is this sort of thing supported
at all in Dot net?
If it can't be done as described above, any suggestion on how to
accomplish the desired task?
Thanks
parsing of data. The attribute will determine if the current property
is to be populated based on the version of the data. As such I need to
be able to create the attribute with the version and some other values
for the version. So I tried the following (typed for the example, not
the actual code).
defined the constructor for the Attrib as:
public MyAttrib(params object[] versions)
and defined the class as:
public MyClass
{
private string prop1;
[MyAttribute(new VersionInfo("1.0", "Description"), new
VersionInfo("2.0", "Description"))]
public string Prop1
{
get { return prop1; }
set { prop1 = value; }
}
}
The class fails to compile with the follwoing error:
An attribute argument must be a constant expression, typeof
expression or array creation expression
Have I defined something incorrectly? Is this sort of thing supported
at all in Dot net?
If it can't be done as described above, any suggestion on how to
accomplish the desired task?
Thanks