Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0561

Visual Studio .NET 2003

'function' : cannot override 'accessor' because it is a special compiler-generated method

A property declaration created a hidden virtual method (accessor) named Getproperty_name. That accessor name conflicts with a method name. You can only override this accessor method through a property override not a method override.

The following sample generates CS0561:

// CS0561.cs
class B
{
   public virtual int Prop
   {
      get
      {
         return 0;
      }
   }
}

class C : B
{
   public override int get_Prop()   // CS0561
   {
      return 0;
   }

   /* Try the following instead:
   public override int Prop
   {
      get
      {
         return 0;
      }
   }
   */

   public static void Main()
   {
   }
}
Show:
© 2014 Microsoft