Naimish Makwana
C# - Why base class must come before any interfaces when declaring a derived class?

When we are implementing both interface and base class in any derived class than we must have to follow the sequnce where we have to first put base class and than Interface.
Ex: If we don’t follow the sequnce than we will get error “Base class must come before any interface”.

  1. public class BaseClass
  2. {
  3. //
  4. }
  5. public interface IMyInterface
  6. {
  7. //
  8. }
  9. public class DerivedClass : IMyInterface, BaseClass //ERROR HERE : CS1722: Base class 'BaseClass' must come before any interface.
  10. {
  11. //
  12. }

Why is it necessary to extend the class first and then implement the inteface?

By Naimish Makwana in C# on Jan 12 2023


Most Popular Job Functions


MOST LIKED QUESTIONS