C#C
C#7mo ago
Mark_P

✅ Can I put an extension method directly on an enum, not a value in the enum?

If I have an enum
public enum MyEnum{one, two, three}

can I put an extension method on it so I can use it like this
MyEnum.MyExtensionMethod()

rather than
MyEnum.one.MyExtensionMethod()

And I only want it on that specific enum, not all enums
Was this page helpful?