Re: About Override Class Question
- From: Marcus Andrén <a@xxx>
- Date: Fri, 30 Sep 2005 10:23:37 +0200
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
.
- References:
- Re: About Override Class Question
- From: Tasos Vogiatzoglou
- Re: About Override Class Question
- Prev by Date: GridView question ASP.NET 2.0
- Next by Date: RE: Combo Box Simple Style
- Previous by thread: Re: About Override Class Question
- Next by thread: Re: About Override Class Question
- Index(es):
Relevant Pages
|
Loading