Well, the more important thing is what does Class B and Class A do with
Person.Peter in the constructor? If it uses it in the initialization the
class, then there's no way you can really change this.
If on the other hand, it's simply stored in a field for later use, then you
can use reflection to change the field in the base class by simply getting
the FieldInfo object for the field and setting the value. This isn't really
"recommended", but sometimes you have to do things like this. This will
require reflection permissions in the environment that the code is running,
or it will fail.
Pete Davis
"bill tie" <bi*****@discussions.microsoft.com> wrote in message
news:5F**********************************@microsof t.com...
Consider the following classes A and B.
public class A
{
public enum Person
{
Peter = 0,
Paul = 1
}
public A(Person name)
{
}
}
public class B : A
{
public B() : base(Person.Peter)
{
}
}
public class C : B
{
// ????
}
- A and B are black boxes. I've no way of altering their code.
- I write the C class. I want my C class to have all the capabilities of
the B class except for the enumeration "Person.Peter". I want
"Person.Paul".
Is this possible? How should I define the C class?
Thank you.