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.
'type' : interfaces cannot declare types
Prior to C# 8.0, an interface could not contain user-defined types. Starting with C# 8.0, interfaces can declare nested types as part of the default interface members feature.
In modern C# (C# 8.0 and later), this error is no longer generated for nested types in interfaces. The compiler now allows interfaces to contain nested classes, structs, interfaces, enums, and delegates.
Historical example
The following sample generates CS0524 in C# versions prior to 8.0, but is valid in modern C# versions:
// This code is valid in C# 8.0 and later
public interface IExample
{
public class NestedClass // Valid since C# 8.0
{
}
}