What is the difference between a static class and a singleton?
Quick Answer
A static class can't be instantiated, has only static members, and can't implement an interface or be injected — it's for pure stateless helpers (Math, Path). A singleton is a normal class with one instance; it can implement an interface, be injected, and hold state — so it's testable in a way a static class isn't.
A static class is just a container for static methods — you can't create one, it can't implement an interface, and you can't inject it, so it's only appropriate for stateless helpers like Math. A singleton is a real class that happens to have one instance; it can implement an interface and be injected, which means I can swap it for a fake in tests. So when people say “make this a singleton,” in .NET that means register it with the container's singleton lifetime and inject the interface — not make it a static class.
- Static class: no polymorphism, no DI, hard to fake in tests. Fine for genuinely pure functions.
- Singleton: use the DI container's singleton lifetime and inject the interface — you get one instance and testability.
- Static constructors run once, lazily, and are thread-safe by the runtime — but static mutable state is a common bug/testing headache.
- Rule: if it has state or you'd want to mock it, it's a singleton (via DI), not a static class.