Edit

Share via


Compiler Error CS0506

'function1' : cannot override inherited member 'function2' because it is not marked "virtual", "abstract", or "override"

A method was overridden that was not explicitly marked as virtual, abstract, or override.

The following sample generates CS0506:

C#
// CS0506.cs  
namespace MyNameSpace  
{  
   abstract public class ClassX  
   {  
      public int i = 0;  
  
      public int f()  
      {  
         return 0;  
      }  
      // Try the following definition for f() instead:  
      // abstract public int f();  
   }  
  
   public class ClassY : ClassX  
   {  
      public override int f()   // CS0506  
      {  
         return 0;  
      }  
  
      public static int Main()  
      {  
         return 0;  
      }  
   }  
}