Compiler Error CS1102

The parameter modifier 'out' cannot be used with 'this'.

When the this keyword modifies the first parameter of a static method, it signals to the compiler that the method is an extension method. No other modifiers are needed or allowed on the first parameter of an extension method.

To correct this error

  • Remove the unauthorized modifiers from the first parameter.


The following example generates CS1102:

// cs1102.cs
// Compile with: /target:library.
public static class Extensions
    // No type parameters.
        public static void Test(this out int i) {} // CS1102

    //Single type parameter
        public static void Test<T>(this out T t) {}// CS1102

    //Multiple type parameters
        public static void Test<T,U,V>(this out U u) {}// CS1102

See Also


Extension Methods (C# Programming Guide)

this (C# Reference)

out (C# Reference)