Compiler Error CS1106
Extension methods must be defined in a non generic static class.
Extension methods must be defined as static methods in a non-generic static class.
The following example generates CS1106:
C#
// CS1106.cs
public class NonStaticClass // CS1106
{
public static void ExtensionMethod1(this int num) {}
}
public static class StaticGenericClass<T> // CS1106
{
public static void ExtensionMethod2(this int num) {}
}
public static class StaticClass // OK
{
public static void ExtensionMethod3(this int num) {}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: