Adding to the message.
Parent p = new Parent(); Child c = new Child();
Using the above, you can only access parent (p1) properties, although it does contain a reference to a child object.
var p= new Parent(); var c= new Child(); var p1 = new Child();
when using "var" instead of a class, you have access to the properties of the parent and child classes. it behaves like creating an object for a child class.
Anand Ramachandran May 6 '16 at 6:06 a.m. 2016-05-06 06:06
source share