473,395 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Nested classes within .NET Framework

Hi --

I'm trying to find an example of a nested class implemented within the .NET
Framework itself but without much success. I don't suppose that anybody
knows of such an example off the top of their head, do they?

Many thanks!

--
Best Regards,

Christopher Ireland.
Nov 15 '05 #1
4 1957
If you are thinking of classes within classes (like java), I believe .Net
uses structs instead. Those can contain methods and implement interfaces
(not sure about inheritance).

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
For a laugh, try web browsing with Opera's User Mode with Nostalgia enabled
Nov 15 '05 #2
Christopher Ireland <ch*********@removemee.irelandlife.net> wrote:
I'm trying to find an example of a nested class implemented within the .NET
Framework itself but without much success. I don't suppose that anybody
knows of such an example off the top of their head, do they?


Well, the following shows all the *public* nested types within
mscorlib.dll:

using System;
using System.Reflection;

class Test
{
static void Main()
{
Assembly mscorlib = typeof(string).Assembly;

Type[] types = mscorlib.GetTypes();

foreach (Type t in types)
{
if (t.IsNestedPublic)
{
Console.WriteLine(t);
}
}
}
}

This only yields
System.Environment+SpecialFolder
System.Runtime.InteropServices.ELEMDESC+DESCUNION
System.Runtime.InteropServices.VARDESC+DESCUNION

There may be others in System.dll etc. In particular, there are loads
in System.Windows.Forms.dll - although many of those don't have public
enclosing type (which makes the nested type being public pretty
pointless, I think).

To see *all* nested types in an assembly (including automatically
generated ones) change the test to

if (t.DeclaringType != null)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Morten Wennevik <Mo************@hotmail.com> wrote:
If you are thinking of classes within classes (like java), I believe .Net
uses structs instead. Those can contain methods and implement interfaces
(not sure about inheritance).


No, structs are entirely different from nested classes. It's true that
..NET doesn't have any equivalent to Java's inner classes. Even nested
types in .NET are slightly different to Java's static nested classes in
terms of access between the two classes.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #4
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Well, the following shows all the *public* nested types within
mscorlib.dll:


Cheers Jon.

--
Best Regards,

Christopher Ireland
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Joshua Beall | last post by:
Hi All, I remember reading that both nested classes and namespaces would be available in PHP5. I know that namespaces got canceled (much sadness...), however, I *thought* that nested classes...
3
by: Erik Bongers | last post by:
Hi, Nested classes only seem to be able to access static members of the surrounding class : class SurroundingClass { public: class InnerClass { public:
2
by: Alfonso Morra | last post by:
I have a (largish) "master" header file (>130 loc). I also have a number of seperate "satelite" header files which declare various objects used by the object declared in the "master" header file....
11
by: C# Learner | last post by:
Is it not possible to declare a nested class in a seperate file from its "parent" class -- i.e. in a similar way to the idea of spreading namespaces over more than one file?
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
1
by: Raju Joseph | last post by:
Hi All, We are in the process of developing an N-Tier app using VB.NET. We are extensively using classes (entity objects) in our design. Further, most of the times, we do have to specify nested...
6
by: moondaddy | last post by:
I'm new to c# and am wondering if its possible to access members of a nested class. Can someone please advise? Thanks. class Program { static void Main(string args) { try { Test1 obj =...
5
by: Jake K | last post by:
What purpose does nesting a class inside another class typically server? Are there conditions where this would be beneficial? Thanks a lot.
2
card
by: card | last post by:
Hi everyone, I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes: #include...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.