C# Error CS1676 – Parameter {0} must be declared with the ‘{1}’ keyword

C# Error

CS1676 – Parameter {0} must be declared with the ‘{1}’ keyword

Reason for the Error & Solution

Parameter ‘number’ must be declared with the ‘keyword’ keyword

This error occurs when the parameter type modifier in an anonymous method is different from that used in the declaration of the delegate you are casting the method to.

The following sample generates CS1676:

// CS1676.cs  
delegate void E(ref int i);  
class Errors
{  
   static void Main()  
   {  
      E e = delegate(out int i) { };   // CS1676  
      // To resolve, use the following line instead:  
      // E e = delegate(ref int i) { };  
   }  
}  

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