This documentation is archived and is not being maintained.

Compiler Error CS1527

Visual Studio 2008

Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal

Type declarations in a namespace can have either public or internal access. If no accessibility is specified, internal is the default.

The following sample generates CS1527:

// CS1527.cs
namespace Sample
{
   private class C1 {};             // CS1527
   protected class C2 {};           // CS1527
   protected internal class C3 {};  // CS1527
}

The following example generates CS1527 because when no namespace is explicitly declared in your program code, all type declarations are located implicitly within the global namespace.

//cs1527_2.cs
using System;

protected class C4{}
private struct S1{}
Show: