Skip to content

Static interface members C# 11.0correctnesstype safety

Allow members of an interface to be static abstract or virtual.

Interfaces have always been a way to define a contract that classes must implement but was always limited to instance members.

In C# 11.0, you can now define static abstract or virtual members on an interface.

Code

C#
public interface IConcateable<T> where T:IConcateable<T>
{
    static abstract T Concat(T a, T b);
}
C#
public interface IConcateable<T> where T:IConcateable<T>
{
    T Concat(T other);
}

Notes

More information