?
=?ISO-8859-1?Q?=22Andr=E9s_G=2E_Aragoneses_=5B_kno
I have a simple class:
public class BaseClass
{
private string propertyA;
protected string PropertyA
{
get { return propertyA; }
set { propertyA = value; }
}
private string propertyB;
protected string PropertyB
{
get { return propertyB; }
set { propertyB = value; }
}
}
Now I have a derived class:
public class DerivedClass
{
private string propertyC;
protected string PropertyC
{
get { return propertyC; }
set { propertyC = value; }
}
}
How can I create a constructor method of DerivedClass that receives an
object from the base class and casts it to derived class (so as to copy
the value of the properties they have in common)?
I ask this because this constructor obviously raises a compile error:
public DerivedClass(BaseClass oObj)
{
this = (DerivedClass)oObj;
}
Is there a method to do this apart from Reflection?
Thanks in advance.
Andrés [ knocte ]
--
public class BaseClass
{
private string propertyA;
protected string PropertyA
{
get { return propertyA; }
set { propertyA = value; }
}
private string propertyB;
protected string PropertyB
{
get { return propertyB; }
set { propertyB = value; }
}
}
Now I have a derived class:
public class DerivedClass
{
private string propertyC;
protected string PropertyC
{
get { return propertyC; }
set { propertyC = value; }
}
}
How can I create a constructor method of DerivedClass that receives an
object from the base class and casts it to derived class (so as to copy
the value of the properties they have in common)?
I ask this because this constructor obviously raises a compile error:
public DerivedClass(BaseClass oObj)
{
this = (DerivedClass)oObj;
}
Is there a method to do this apart from Reflection?
Thanks in advance.
Andrés [ knocte ]
--