Search code examples
c#visual-studioextension-methods

Put extension method in one file or in many files?


I use VS 2012 and I have some extension methods.

I want to know the best strategy to organize extension methods.

I can either create one file like ExtensionMethods.cs and put all of the extension methods inside or create multiple *.cs files and put each method inside one file. Surely, some other ways may be assumed.

Here, I'm looking for nice and bright ideas.


Solution

  • I think the more important question is the static (non-generic) class where you want to put all the extension methods. It would be better if you can have related extension methods in a single static class and have a single code file for each static class.