A nice use for Nested classes in C#.
In C# you can put classes in a namespace like this:
namespace Foo { public class Bar {...} }
or nest them like this:
public class Foo { public class Bar(){...} }
Nesting classes in C# is more like C++ than Java (creating a new Foo does not imply a new Bar), so deciding which to use is to some extent a stylistic decision. That said I ran into an interesting place where nesting turned out to have a subtle advantage. I had a common base class with a bunch of derived classes, each representing a particular type of input (statements in a program in this case), so something like this:... [Managed Space]
10:16:38 AM
|