Export (0) Print
Expand All
Expand Minimize

Compiler Error CS1609

Modifiers cannot be placed on property or event accessor declarations

Modifiers can only be placed on property or event declarations and not on the property or event accessor declarations. For more information, see Accessors.

The following sample generates CS1609:

// CS1609.cs
class c
{
   public int Prop   //  modifier on property declaration OK
   {
      get
      {
         return 0;
      }
      private set   // CS1609
      // try the following line instead
      // set
      {
      }
   }

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