I like using private nested classes, except that they always feel so cluttered. Normally I put them in their own #region
, but I would prefer them to be separate from their parent class in terms of location, and I also don't really want them in separate files. What I decided to do was to make their parent class partial, and then to place the child class physically below the parent class in the file.
Unfortunately it seems that you can't have more than one partial class definition per file either.
(EDIT: it turns out you can have more than one partial part per file; it's just the forms designer that doesn't like it.)
What I would really like to do is something like (all in one file):
internal class Parent
{
}
private class Parent.Child1
{
}
private class Parent.Child2
{
}
but it seems like all I can do is either generate a new source file for every new child class, or arrange them like this:
internal class Parent
{
private class Child1
{
}
private class Child2
{
}
}
Is there any way to accomplish what I'm trying to do here?