I am relatively new to C# and each time I begin to work on a C# project (I only worked on nearly mature projects in C#) I wonder why there are no inner classes?
Maybe I don't understand their goal. To me, inner classes -- at least private inner classes -- look a lot like "inner procedures" in Pascal / Modula-2 / Ada : they allow to break down a main class in smaller parts in order to ease the understanding.
Example : here is what is see most of the time :
public class ClassA { public MethodA() { <some code> myObjectClassB.DoSomething(); // ClassB is only used by ClassA <some code> } } public class ClassB { public DoSomething() { } } Since ClassB will be used (at least for a while) only by ClassA, my guess is that this code would be better expressed as follow :
public class ClassA { public MethodA() { <some code> myObjectClassB.DoSomething(); // Class B is only usable by ClassA <some code> } private class ClassB { public DoSomething() { } } } I would be glad to hear from you on this subject - Am I right?