Another way of looking at it:
If an interface
could have a static method:
interface IFoo
{
static void Bar();
}
class Foo1 : IFoo
{
public static void Bar() { ... }
}
class Foo2 : IFoo
{
public static void Bar() { ... }
}
and you invoked it:
IFoo.Bar();
there would be no way to known
which implementation you would end up calling. Would that call
Foo1.Bar
or
Foo2.Bar
?
You might decide you want it to call
both implementations. Which
might work, until you introduce return values, or
ref
/
out
parameters:
interface IFoo
{
static int Bar();
}
class Foo1 : IFoo
{
public static int Bar() { return 42; }
}
class Foo2 : IFoo
{
public static int Bar() { return 84; }
}
int x = IFoo.Bar();
An interface is a contract for things you can do with
an instance of a class. A static interface, or static members on an interface, doesn't really make any logical sense.
Edit: Since this has been dragged back up into the "active" list, it's probably worth saying that as of C#11, this information no longer applies. Interfaces can now have static virtual members:
Explore static virtual members in interfaces | Microsoft Learn[
^]