Compiler Error CS1527
Elements defined in a namespace cannot be explicitly declared as private, protected, protected internal or private protected.
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
private protected class C4 {} // 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 {}
.NET feedback
.NET is an open source project. Select a link to provide feedback: