I have the following issue:
public class ChildClass{
public Object Parent = null;
}
public class ParentClass{
public ChildClass CreateChild(){
return new ChildClass{ Parent = this; }
}
}
I got a bit stuck understanding object initializers. In the CreateChild() method, does this refer to ParentClass or ChildClass?
thiswill refer the the class it is in.In the example,
thiswill be an instance ofParentClass, since it is declared within the body ofParentClass.