Here is an exerpt from MSDN article...
Nested classes are useful when an object will logically contain subordinate
objects, but other objects would have use for those objects. An example
might be a Wheel class. This could be a class that clients could create and
use wherever a wheel might be needed in their application. But except in
the most primitive implementations, a wheel is not just a single object,
but is composed of several subordinate objects, each of which build the
wheel. A wheel might have a Rim object, Tire object, Spoke objects and
other objects, without which the wheel could not function. But the average
user would have no need to create a spoke, or a rim, or a bearing — all
he's interested in is the wheel.
In a case like this, it makes sense for the Wheel class to contain the
implementation for all of its subordinate classes. This way, the wheel can
create and manage any contained objects it may need while conveniently
hiding the details of this implementation from the client. Those
subordinate objects the client might reasonably need to have contact with
now and again (for example, a Tire object) can be exposed as part of the
public object model, and those that a client should never see (for example,
a Bearings collection) could be declared private and hidden.
--------------------
From: "Daniel Billingsley" <db**********@NO.durcon.SPAAMM.com>
References: <07****************************@phx.gbl>
<MP************************@msnews.microsoft.com >Subject: Re: Access from inner classes
Date: Mon, 10 Nov 2003 09:14:04 -0500
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <ux**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 68-74-16-211.ded.ameritech.net 68.74.16.211
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:198029
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
Well, here's a new concept for me. What's the point of this generally? I
can see maybe to severely limit the visibility of ClassB even within the
assembly, but is that it?
public class ClassA
{
private class ClassB
{
}
}
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft. com...
There are no inner classes in C#, only nested classes - the equivalent
of nested classes marked as "static" in Java. To call A1, you'd need an
instance of A (well, an instance of a subclass of A, in this case). How
you get that is up to you.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Rakesh, EFT.
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm