Compiler Error CS1518
Expected class, delegate, enum, interface, or struct
A declaration was found that is not supported in a namespace. Inside a namespace, the compiler accepts only classes, structs, enums, interfaces, namespaces, and delegates.
The following sample generates CS1518:
C#
// CS1518.cs
namespace x
{
sealed class c1 {}; // OK
namespace f2 {}; // OK
sealed f3 {}; // CS1518
}
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: