Join Nostr
2026-10-27 14:07:56 UTC

codementor on Nostr: Learn: Interface or abstract class? Interface: a contract with no instance fields ...

Learn: Interface or abstract class?

Interface: a contract with no instance fields (since C# 8 it can have default method bodies). Many per class. Best for "can do": IComparable, IDisposable, services you inject.
Abstract class: a partial implementation. Only one base class. Best for "is a" families that share code and state.

A common interview answer: start with an interface; add an abstract base class when several implementations repeat the same code.

#tip · TIP-050