© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
14 replies
Saiyanslayer

When to use a static helper class vs extension methods

When adding a static class, what criteria do you use to determine if it should be a helper class or an extension class?

For example, I have a recursive hierarchical data structure (has Children list of more of itself) and I want to write methods to help searching and iterating through it.

I could have a helper class like:
public static class TreeNavigation {
  public static bool NodeExists(Root root, Node node){...}
}
public static class TreeNavigation {
  public static bool NodeExists(Root root, Node node){...}
}


or a extension class like:
public static class TreeExtensions {
  public static bool NodeExists(this Root root, Node node){...}
}
public static class TreeExtensions {
  public static bool NodeExists(this Root root, Node node){...}
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Static helper class/method design question
C#CC# / help
2y ago
❔ Static methods
C#CC# / help
3y ago
✅ Extension Methods
C#CC# / help
2y ago
Extension Methods
C#CC# / help
2y ago