Resolving Ambiguity with the new Keyword : Override : Class C# Examples


C# Examples » Class » Override »

 

Resolving Ambiguity with the new Keyword









    
using  System;
      
public  class  BaseClass
{
        protected  int  Value;
      
        public  BaseClass()
        {
                Value  =  123;
        }
      
        public  void  PrintValue()
        {
                Console.WriteLine("Value:  "  +  Value);
        }
}
      
public  class  DerivedClass  :  BaseClass
{
        new  public  void  PrintValue()
        {
                Console.WriteLine("Value  =  "  +  Value);
        }
}
      
class  MainClass
{
        public  static  void  Main()
        {
                DerivedClass  DerivedClassObject  =  new  DerivedClass();
      
                DerivedClassObject.PrintValue();
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Override