Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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 example generates CS1518.
// CS1518.cs
namespace NS
{
// OK.
sealed class c1 {};
// OK.
namespace f2 {};
// Generates CS1518. A function cannot be defined here.
public int aFunction() { }
}
Change History
Date |
History |
Reason |
---|---|---|
March 2009 |
Clarified the example. |
Customer feedback. |