C# Error CS1553 – Declaration is not valid; use ‘{0} operator (…’ instead

C# Error

CS1553 – Declaration is not valid; use ‘{0} operator (…’ instead

Reason for the Error & Solution

Declaration is not valid; use ‘modifier operator <dest-type> (…’ instead

The return type for a must immediately precede the parameter list, and modifier is either implicit or explicit.

The following sample generates CS1553:

// CS1553.cs  
class MyClass  
{  
   public static int implicit operator (MyClass f)   // CS1553  
   // try the following line instead  
   // public static implicit operator int (MyClass f)  
   {  
      return 6;  
   }  
  
   public static void Main()  
   {  
   }  
}  

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...