Can anyone tell my where I find information about implementing classes inside other classes For example:
Class Outer
{
Class Inner_1
{
}
Class Inner_2
{
}
}
- How to let the outer class use the inner classes
- How to let the inner classes use the outer class
- How to collaborate between inner classes
On beforehand thank you - dampbarn

Internal classes
MartinPEvans
Hi dampbarn,
here I have an assortment of links I hope you find all useful. First of all I want to say that the fact a class B is defined inside a class A doesn't imply that any instance of A holds an instance of B, except if you declare a B class member inside A
The idea of nested classes (also known as inner classes) is defining a class that makes sense only in the context of a container class. Do you remember, from UML, the two kinds of associations You had
So, nested classes make more sense for the later case, but still you have to declare through properties the visibility container/containee and/or vice versa
Don't want you to get boried, here's my links:
Stephen Turner
I found a place to start:
http://en.csharp-online.net/Nested_Classes
If othters have links to more extended examples, they are very welcome.
dampbarn
duck16
Fantastic, dampbarn
Consider closing the thread if you think that, with the comments so far, your initial issue is covered. That doesn't prevent anyone to continue posting interesting stuff, but at least serves for the forum engine purposes, to track how many threads are still pending, how many are being solved, etc
To close a thread you can just select one or more answers and tag them as useful
Thanks
Diego
TouchTheSquid
Kestutis
Hi Diego Dagum
Thank you for your reply. I find you links useful.
I do understand the distinction between Composition and Aggregation, and what got me interested in nested classes was after reading about Object Heuristics*, where the author recommends the use of nested classes if one class are using one or more classes that are not used by others. In this case he recommends deep instead of wide implementation so that only the outer class knows of the inner classes it uses. What I was after was some more extended and various examples of how experienced programmers use nesting, and my own provided link actually gives a very good example of what I was after. Since finding this link, I have a pretty good idea of how and when to use nested classes.
Thank you for posting the links. They extend what I found myself.
* Object-Oriented Design Heuristics by Arthur J. Riel, Addison Wesley, 1996
dampbarn