Override without 'override' keyword : Override : Class C# Examples


C# Examples » Class » Override »

 

Override without 'override' keyword









    
using  System;

public  class  A
{
        public  virtual  void  SomeMethod()  {
                Console.WriteLine(  "A::SomeMethod"  );
        }
}

public  class  B  :  A
{
        public  void  SomeMethod()  {
                Console.WriteLine(  "B::SomeMethod"  );
        }
}

public  class  MainClass
{
        static  void  Main()  {
                B  b  =  new  B();
                A  a  =  b;

                a.SomeMethod();
        }
}
    
   
  
   



Output

A::SomeMethod


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Override