Re: About Override Class Question



On Fri, 30 Sep 2005 00:40:02 -0700, "Sunny"
<Sunny@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>Have a way change the instance of a to instance of type B, in this example?
>Thanks
>

Why would you want to do this in the first case?

An object is created with a specific type and it is impossible to
change that type. Anyway, the simplest way to do what you seem to want
would be to create a method in class B that creates a new instance of
class A and fills it with all relevant data. Something like this:

public A ConvertToBase()
{
A a = new A();
//Copy properties here
return a;
}

And in the main method do something like this:

B b = new B();
A a = b.ConvertToBase();


--
Marcus Andrén
.



Relevant Pages


Loading