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.

Example

The following sample generates CS1518:

// CS1518.cs  
namespace x  
{  
   sealed class c1 {};      // OK  
   namespace f2 {};         // OK  
   sealed f3 {};            // CS1518  
}