Ken Shen

Ken Shen

  • NA
  • 5
  • 1.6k

Conditional Attribute question

Apr 20 2012 7:12 PM
I want to make attribute of some fields conditional, as below:

enum AttrType
{
Type1,
Type2
}

public class Shape
{
[MyAttribute(AttrType.Type1)]
mArea;
}

public class Circle:Shape
{
[Make it AttrType.Type2]
mArea;
[Make it AttrType.Type1]
mRadius;
}

If it is base class A, and mRadius is not defined, I want mArea has AttrType.Type1. If it is in derived class B, and mRadius is defined, I want mArea has AttrType.Type2 and mRadius has AttrType.Type1

How to make it work?

Thanks,

Answers (5)