I have below two classes.
When execute this line,
Child myChildObj = new Child();
does this create separate two objects (Parent and Child) ?
Or just a single child object which includes both the parent methods and attributes ?
Update: I want to know in CLR, whether it actually creates a Parent object (which is not accessible) at the runtime.
I have seen the following quote in tutorialspoint website.
The derived class inherits the base class member variables and member methods. Therefore the super class object should be created before the subclass is created. You can give instructions for superclass initialization in the member initialization list.
I have used the following code to verify this, and I got the same hashCode value for both child and parent objects.
Console.WriteLine("child object hashcode : "+this.GetHashCode());
Console.WriteLine("base object hashcode : "+base.GetHashCode());


Parentand as aChild: base()from your constructor to call the constructor of the super class". It's not a very clear statement. Also, about the hash codes: "GetHashCode always returns identical hash codes for equal object references", sothis.GetHashCode()andbase.GetHashCode()return the same.