0 out of 3 rated this helpful - Rate this topic

Compiler Error CS1014

A get or set accessor expected

A method declaration was found in a property declaration. You can only declare get and set methods in a property.

For more information on properties, see Using Properties (C# Programming Guide).

The following sample generates CS1014.

// CS1014.cs
// compile with: /target:library
class Sample
{
   public int TestProperty
   {
      get
      {
         return 0;
      }
      int z;   // CS1014  not get or set
   }
}
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ