Prakash Tripathi

Prakash Tripathi

  • 28
  • 40.8k
  • 6.3m

C# OOPs question

Mar 11 2015 10:18 PM
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)