I usually stick with one class per file. But I will make exceptions for groups of similar constructs that are used project-wide. For example:
- An EventArgs.cs that contains any
EventArgs
subclasses, since they're usually only 5-10 lines of code each, but they typically are used by several different classes. Alternatively, I might put the EventArgs
classes in the same file as the class that declares the events.
- A Delegates.cs that contains Delegates that are used throughout the project, since they're usually only 1 line each. Again, the alternative is to put them in the same file with the class that exposes/consumes them.
- An Enums.cs that contains
enum
s used throughout the project. (If there's an enum
that's used only by one class, I'll usually make it private
to that class.)