derived entity instance in base type is null at initialization time
I have say ClassA entity = new ClassA(){firstname="blah", age=28} Also class A inherit a ClassB, so in ClassB contructor I want to do something like ClassB() { do something with classA entity, but the think is that the entity instance is still null, it goes thru the newing up stage then after the values firstname and age get set, is there a way around this to be able to get the not null instanc开发者_开发问答e of the derived class and pass it to the base class? Thankx. Using C# 4.
are you calling ClassA's constructor from ClassB?
public class ClassA
{
}
public class classB
{
public ClassB(): base()
{
//Do something with ClassA
}
}
in client code i have ClassA c = new ClassA(){firstname=""}
in the library it goes like this:
public partial class ClassA: ClassB {
}
public class classB { public ClassB() { AddValidation(..);//here i want to acces the instance of entity ClassA that was populated in client code. } }
精彩评论