Reputation: 7261
If I have a class containing many Extension Methods, should I worry about the overhead of "using" it if I'm only using one of those Extension Methods?
If this is the case, should I perhaps put all Extension Methods in their own classes? Or perhaps there is a way to "use" a single Extension Method? (E.g., something like: using StringMethods.RecursiveJoin;
?)
Upvotes: 0
Views: 147
Reputation: 108790
It likely increases the compile time very very slightly. And there is no runtime overhead at all. So no reason to worry from a performance point of view.
The only thing I'd worry about is whether the design is good. Should all of those methods really be extension methods, or are some of them better off as normal static methods or even instance methods? But that question can't be answered without knowing what your extension methods do.
Upvotes: 3
Reputation: 62246
Not very sure what is exact point of "overhead", but you if you are thinking about "importing" a single method, it's not possible. What you can do is to move/copy that method into another class, that use only you, if it will give the code more "localized" feeling (it's difficult to dedcut without seeing all project).
This will be code-layout architecture improvement, if will, but not memory, or performance.
Upvotes: 0