What is the difference between method overloading and method overriding?
Quick Answer
Overloading = multiple methods with the same name but different parameters in the same type; the compiler picks one based on the arguments (compile-time / static polymorphism). Overriding = a derived class replacing a virtual base method with the same signature; the runtime picks one based on the actual object (run-time / dynamic polymorphism).
Overloading is when I have several methods with the same name in a type but different parameter lists — the compiler figures out which one to call from the arguments I pass, so it's decided at compile time. Overriding is inheritance: a subclass provides its own implementation of a virtual method from the base class with the exact same signature, and the runtime decides which one runs based on the actual object. Overloading is static polymorphism, overriding is dynamic polymorphism.
| Overloading | Overriding | |
|---|---|---|
| Where | Same class (or via inheritance) | Base + derived class |
| Signature | Must differ (parameters) | Must match exactly |
| Return type alone | Not enough to overload | Must match (or covariant) |
| Keyword | None | virtual / override |
| Resolved | Compile time | Run time (vtable) |
Overloading is a convenience — Console.WriteLine has ~19 overloads. Overriding is how polymorphism works — a Shape.Area() that each subclass implements.