Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error CS0106

The modifier 'modifier' is not valid for this item

A class or interface member was marked with an invalid access modifier. The following examples describe some of these invalid modifiers:

  • The static and public modifiers are not permitted on interface methods.

  • The public keyword is not allowed on an explicit interface declaration. In this case, remove the public keyword from the explicit interface declaration.

  • The abstract keyword is not allowed on an explicit interface declaration because an explicit interface implementation can never be overridden.

In prior releases of Visual Studio, the static modifier was not permitted on a class, but static classes are allowed starting with Microsoft Visual Studio 2005.

For more information, see Interfaces (C# Programming Guide)

The following sample generates CS0106.

// CS0106.cs
namespace MyNamespace
   interface I
      void m();
      static public void f();   // CS0106

   public class MyClass
      public void I.m() {}   // CS0106
      public static void Main() {}

Community Additions

© 2015 Microsoft