How do I get the base class data into the child class object when using keyword as
. I tried the below code but it returns null
data.
class BaseC
{
public int BaseId { get; set; }
public string BaseName { get; set; }
}
class DerivedC: BaseC
{
public int DerivedId { get; set; }
public string DerivedName { get; set; }
}
class Program
{
static void Main(string[] args)
{
BaseC baseC = new BaseC();
baseC.BaseId = 1;
baseC.BaseName = "base class name ";
var derivedC = baseC as DerivedC;
}
}