Why Doesn’t C# Allow Static Methods to Implement an Interface?

Technology CommunityCategory: C#Why Doesn’t C# Allow Static Methods to Implement an Interface?
VietMX Staff asked 3 years ago

My (simplified) technical reason is that static methods are not in the vtable, and the call site is chosen at compile time. It’s the same reason you can’t have override or virtual static members. For more details, you’d need a CS grad or compiler wonk – of which I’m neither.

You pass an interface to someone, they need to know how to call a method. An interface is just a virtual method table (vtable). Your static class doesn’t have that. The caller wouldn’t know how to call a method. (Before i read this answer i thought C# was just being pedantic. Now i realize it’s a technical limitation, imposed by what an interface is). Other people will talk down to you about how it’s a bad design. It’s not a bad design – it’s a technical limitation.