© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•8mo ago•
8 replies
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}
public enum MyEnum{one, two, three}

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

rather than
MyEnum.one.MyExtensionMethod()
MyEnum.one.MyExtensionMethod()

And I only want it on that specific enum, not all enums
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

❔ Attributes on a enum value?
C#CC# / help
3y ago
✅ Why return IServiceCollection in an extension method?
C#CC# / help
3y ago
CA1860: Avoid using 'Enumerable.Any()' extension method
C#CC# / help
13mo ago
How to put enum values in a list [SOLVED]
C#CC# / help
4y ago