"Joel Moore" <as*******@asdaadad.com> wrote in message
news:Xn******************************@207.46.248.1 6...
Yes, the nested class has access to all the members of the enclosing
class (or so the docs say) but I didn't see an example of how to
access the variables. I'll look it up when I get home.
As a guess, I'm sure you can just refer to the members by name. I'm
particularly interested in situations where you define other members
with the same names in the nested class and then you want to refer to
the member in the enclosing class. Perhaps the best advice in that
situation is "don't set it up that way," but let's see....
I figured it would but that doesn't seem to be the case. Maybe there's
some sort of default identifier (similar to MyBase or something) that
needs to be used but I can't find anything.
Maybe this is just bad design but in my particular situation it seems like
the best option.
Well, the official word (as you've already discovered) is that you must
provide a reference to the enclosing class in order for the nested class to
access its members. However, doing so allows you to access Private members
of the enclosing class.
I based my original comment on the following passage from MSDN which was
talking about times that implementing a nested class is considered
acceptable:
----
If members of your class need to access private member variables of the
object containing it, you can implement it as a nested class. For example, a
Wheel object might have a private Radius field. If a Spoke object needs to
access the Radius field, it can always have that access if it is implemented
as a nested class.
----
I personally would have added "and you provide the nested class with a
reference to the enclosing class." Oh well.