473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

static classes, nested class, public class

Would you quickly remind me the difference between, regular class,
static class, and nested class?

Thanks
Nov 2 '08 #1
3 3887
"puzzlecracker" <ir*********@gmail.comwrote in message
news:5d**********************************@n33g2000 pri.googlegroups.com...
Would you quickly remind me the difference between, regular class,
static class, and nested class?
A 'regular' class my be used to create object instances for which the class
is the type. Each instance will hold a set of fields which hold values for
that instance only. A class may also contain static members which may be
fields, properties or methods which are common across all instances of the
class. Such static members are accessed through the Type name.

A class marked as static may only contain static members and instances of a
static class cannot be created.

A nested class is a class that is defined inside another class. One
difference that a nested class has from a regular class is that it may be
private where it can only be used inside the class definining it, whereas a
regular class cannot be private.

--
Anthony Jones - MVP ASP/ASP.NET

Nov 2 '08 #2
A 'regular' class can contain any kind of members (fields, methods,
properties, events et cetera), be it static or accessible through an
instance only. A static class, however, can only contain static members and
this is especially useful when the design you choose assumes that this class
cannot or should not be instantiated, for example a set of helper functions.

A nested class is defined within the scope of its 'parent' class--it may be
private or accessible to external classes. You might want to choose to do
this if your design assumes a hierarchical relationship between the two (or
more) classes.
--
Stanimir Stoyanov
http://stoyanoff.info

"puzzlecracker" <ir*********@gmail.comwrote in message
news:5d**********************************@n33g2000 pri.googlegroups.com...
Would you quickly remind me the difference between, regular class,
static class, and nested class?

Thanks
Nov 2 '08 #3
Anthony Jones wrote:
"puzzlecracker" <ir*********@gmail.comwrote in message
news:5d**********************************@n33g2000 pri.googlegroups.com...
>Would you quickly remind me the difference between, regular class,
static class, and nested class?

A 'regular' class my be used to create object instances for which the
class is the type. Each instance will hold a set of fields which
hold values for that instance only. A class may also contain static
members which may be fields, properties or methods which are common
across all instances of the class. Such static members are accessed
through the Type name.
A class marked as static may only contain static members and
instances of a static class cannot be created.

A nested class is a class that is defined inside another class. One
difference that a nested class has from a regular class is that it
may be private where it can only be used inside the class definining
it, whereas a regular class cannot be private.
Also, being a member of the containing class, it has permission to use
private and protected members of the containing class. Static members are
of course accessible directly, and instance members can be explicitly
referenced using a reference to an object derived from the containing class.
Note that these are NOT Java inner classes, there is no implicit reference
to an instance of the containing class.

And Java uses the static keyword very differently with member classes --
Java defaults to defining an "inner class" and you use "static" to get a
normal nested class. C# always gives you a nested class.
Nov 3 '08 #4

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

Similar topics

2
by: newbiecpp | last post by:
Java can declare a static nested class. Does C++ have same thing like? class Outer { public: static class Inner { ... }; .... };
6
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
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. ...
2
by: Bob Day | last post by:
Using VS2003, VB.NET, MSDE... I am looking at a demo program that, to my surprise, has nested classes, such as the example below. I guess it surprised me becuase you cannot have nested subs,...
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
49
by: Ben Voigt [C++ MVP] | last post by:
I'm trying to construct a compelling example of the need for a language feature, with full support for generics, to introduce all static members and nested classes of another type into the current...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
2
by: pinki panda | last post by:
i want to knw the diff between static class and abstract class .i would appreciate if its followed by example
9
by: puzzlecracker | last post by:
It looks like static classes can have non-static member classes -- does it make sense what I just wrote? If not, let me illustrate it: public static class Foo{ private struct Bar{ } }
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.