C# › Interfaces & Abstract Classes

How do static abstract interface members (C# 11+) enable generic math and other 'static polymorphism' patterns?

Advanced

Answer

Interfaces can now declare 'static abstract' members (like operators or factory methods) that IMPLEMENTING TYPES must provide as their own static members — this lets generic code constrained to such an interface call STATIC operations (like T.Zero, or the + operator) on the generic type parameter itself, something previously impossible since static members couldn't be part of a traditional interface contract.
public interface IShapeFactory<TSelf> where TSelf : IShapeFactory<TSelf> {
  static abstract TSelf CreateDefault();
}
public class Circle : IShapeFactory<Circle> {
  public static Circle CreateDefault() => new Circle { Radius = 1.0 };
  public double Radius { get; set; }
}
T CreateShape<T>() where T : IShapeFactory<T> => T.CreateDefault(); // calls the STATIC method generically
Real-world example Enabling .NET's own generic math interfaces (INumber<T>, IAdditionOperators<T,T,T>) which rely entirely on static abstract members.

Common follow-ups: Why couldn't C# achieve this same 'call a static method generically through a constraint' pattern before static abstract interface members existed?