Share via


Compiler Error CS0558

User-defined operator 'operator' must be declared static and public

Both the static and public access modifiers must be specified on user-defined operators.

The following sample generates CS0558:

// CS0558.cs
namespace x
{
   public class ii
   {
      public class iii
      {
         static implicit operator int(iii aa)   // CS0558, add public
         {
            return 0;
         }
      }

      public static void Main()
      {
      }
   }
}