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).

Example

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
   }
}