I have a small query related to OOP concept in C#.
I have an interface
interface intf { string Hello(); } A base class
public class BaseClass { public string Hello() { return "Hello of base class called"; } } A child class that is derived from BaseClass and implements the interface intf as well
public class ChildClass : BaseClass, intf { string Hello() { return "Hello of child class called"; } } Now my question is that when I create an object of ChildClass then when I call the hello method it always calls the hello method of BaseClass. Firstly, why does it call the Hello of the BaseClass? Secondly, how can I call the Hello of the ChildClass?
private void Form1_Load(object sender, EventArgs e) { ChildClass obj = new ChildClass(); MessageBox.Show(obj.Hello()); }