Skip to main content

How to Resolve Error "CS0527: Type 'type' in interface list is not an interface" in C#

The Compiler Error CS0527 is an inheritance syntax error. The message reads: "Type 'TypeName' in interface list is not an interface".

In C#, a class or struct definition follows this syntax: class Child : BaseClass, Interface1, Interface2, ...

C# does not support multiple inheritance of classes (you cannot inherit from two classes). It only supports implementing multiple interfaces.

  • The first item after the colon (:) can be a Base Class OR an Interface.
  • Every subsequent item (after a comma) MUST be an Interface.

If you list a Class, Struct, or Enum in a position where the compiler expects an Interface, CS0527 occurs.

Understanding the Inheritance List

The rule for the inheritance list is strict:

  1. Slot 1: Optional Base Class.
  2. Slots 2+: Interfaces only.

If you write class A : B, C, and both B and C are classes, the compiler looks at C, realizes it is in "Slot 2" (reserved for interfaces), sees that it is a class, and throws the error.

Scenario 1: Attempting Multiple Inheritance

This is the most common cause for developers coming from C++. You want your class to inherit behavior from two different parent classes.

Example of error

public class Logger
{
public void Log() { }
}

public class Database
{
public void Save() { }
}

// ⛔️ Error CS0527: Type 'Database' in interface list is not an interface.
// C# classes can only have ONE base class.
public class DataManager : Logger, Database
{
}

Solution: Use Interfaces or Composition

You must choose one base class. For the other functionality, use an Interface or Composition (holding an instance of the class).

Option A: Use Interfaces

public class Logger 
{
public void Log() { }
}

// Define an interface for the second behavior
public interface IDatabase
{
void Save();
}

// ✅ Correct: Inherits 1 Class, Implements 1 Interface
public class DataManager : Logger, IDatabase
{
public void Save()
{
// Implement save logic here
}
}

Option B: Use Composition

public class DataManager : Logger
{
// ✅ Correct: We "have a" database rather than "being a" database.
private Database _db = new Database();

public void Save() => _db.Save();
}

Scenario 2: Incorrect Order (Base Class Not First)

If a class implements an interface AND inherits from a base class, the Base Class must come first in the list.

Example of error

Putting the interface first.

public class BaseUser { }
public interface IAdmin { }

// ⛔️ Error CS0527: Type 'BaseUser' in interface list is not an interface.
// The compiler treats 'IAdmin' as the Base (valid, if no class follows).
// It then treats 'BaseUser' as a secondary Interface (Invalid, it's a class).
public class SuperUser : IAdmin, BaseUser
{
}

Solution: Reorder the List

Move the base class to the very beginning of the list.

// ✅ Correct: Class first, Interfaces after.
public class SuperUser : BaseUser, IAdmin
{
}
note

Memory Aid: You define What it IS (Base Class) before you define What it DOES (Interfaces).

Scenario 3: Inheriting from Structs or Enums

Classes cannot inherit from Structs or Enums (they are implicitly sealed). If you try to list a struct in the inheritance list, the compiler checks if it's an interface. Since it isn't, CS0527 is raised.

Example of error

public struct Point { public int X, Y; }

// ⛔️ Error CS0527: 'Point' is a struct, not an interface.
public class Location : Point
{
}

Solution: Composition

You cannot inherit from a value type. Hold it as a field instead.

public class Location
{
// ✅ Correct: Composition
public Point Coordinates { get; set; }
}

Conclusion

CS0527 enforces the C# Single Inheritance rule.

  1. Count Base Classes: You can only have one.
  2. Check Order: If you have a base class, it must be the first item after the colon.
  3. Check Types: Everything after the first comma , must be an interface.