G
Guest
If I have a series of classes let's say B, C, and D that all derive from
class A and each of these classes can convert from/to each other. C knows
how to convert from D and B into a C and likewise for the others.
Now, I am given an object that is one of the above types but I am given it
as an A.
Now I know that I can do something like this:
if (a is B) { return (C)(a as B); }
but in my case I would have lots of the if (a is <sometype>) since I have
several of these types. I'm looking for a fast way to convert from one type
to another type when all I have is a reference to a base class.
Thanks
Reggie
class A and each of these classes can convert from/to each other. C knows
how to convert from D and B into a C and likewise for the others.
Now, I am given an object that is one of the above types but I am given it
as an A.
Now I know that I can do something like this:
if (a is B) { return (C)(a as B); }
but in my case I would have lots of the if (a is <sometype>) since I have
several of these types. I'm looking for a fast way to convert from one type
to another type when all I have is a reference to a base class.
Thanks
Reggie