T
Thomas C
I'm looking for the best way to solve the following problem:
public class Foo
{
public void Bar() {}
}
public class Alice : Foo
{
public void Zed() {}
}
Foo foo = new Foo();
What I want to do is to make a new instance of Alice using the data from my
instance of foo like so:
Alice alice = (Alice)foo;
or
Alice alice = new Alice(foo);
Right now, the best solution I have found is to implement a Copy method on
the base class which takes a base class instance and overwrites the local
instance's data with the passed instance's data (e.g. public void Copy(Foo
foo)).
Any better suggestions?
Tom
public class Foo
{
public void Bar() {}
}
public class Alice : Foo
{
public void Zed() {}
}
Foo foo = new Foo();
What I want to do is to make a new instance of Alice using the data from my
instance of foo like so:
Alice alice = (Alice)foo;
or
Alice alice = new Alice(foo);
Right now, the best solution I have found is to implement a Copy method on
the base class which takes a base class instance and overwrites the local
instance's data with the passed instance's data (e.g. public void Copy(Foo
foo)).
Any better suggestions?
Tom