C# Error CS1100 – Method ‘{0}’ has a parameter modifier ‘this’ which is not on the first parameter

C# Error

CS1100 – Method ‘{0}’ has a parameter modifier ‘this’ which is not on the first parameter

Reason for the Error & Solution

Method ‘name’ has a parameter modifier ‘this’ which is not on the first parameter.

The this modifier is allowed only on the first parameter of a method, which indicates to the compiler that the method is an extension method.

To correct this error

  1. Remove the this modifier from all except the first parameter of the method.

Example

The following code generates CS1100 because a this parameter is modifying the second parameter:

// cs1100.cs  
static class Test  
{  
    static void ExtMethod(int i, this Test c) // CS1100  
    {  
    }  
}  

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