2
Reply

C# OOPs question

Prakash Tripathi

Prakash Tripathi

Mar 11 2015 10:18 PM
561
Hi guys,
I have a class like below. My queries are highlited below in Main method.
class Base
{
        internal void DoWork()
      {
         Console.WriteLine("From Base");
      }
}

class Derived: Base
{
      internal void DoWork()
      {
         Console.WriteLine ("From Derived");
      }
      internal void DoMoreWork()
      {
         Console.WriteLine("New Derived");
      }
 
class Program
{
static void Main(string[] args)
{
Derived d1 = new Base();  //Doesn't work why?
Base b1 = new Derived();   //Works why?
b1.DoWork();     //Execute Base method why? 
 }
 
Appreciate your responses for my highlited questions above.
Regards..
 
 

Answers (2)