Forums » .NET » ASP.NET »

difference between static and sealed classes?


Posted Date: 08 Jul 2008      Posted By:: radhamahi1     Member Level: Gold    Member Rank: 381     Points: 1   Responses: 7



difference between static and sealed classes?



Responses

#260596    Author: lalitha      Member Level: Gold      Member Rank: 1536     Date: 08/Jul/2008   Rating: 2 out of 52 out of 5     Points: 1

http://www.dotnetspider.com/forum/118043-Difference-between-static-sealed-classes.aspx

 
#260599    Author: Ratheesh      Member Level: Gold      Member Rank: 722     Date: 08/Jul/2008   Rating: 2 out of 52 out of 5     Points: 1

Static classes

Static classes are used when a class provides functionality that is not specific to any unique instance. Here are the features of static classes in C# 2.0.

Static classes can not be instantiated.
Static classes are sealed so they can not be inherited.
Only static members are allowed.
Static classes can only have static constructor to initialize static members.



sealed classes

when a class defined as sealed its not possible to inherit
its class and properties to the inherited class.Its also
applicable to the class properties.Even class defined as
public its banned to inherit the class.


 
#260600    Author: sivangari      Member Level: Gold      Member Rank: 0     Date: 08/Jul/2008   Rating: 2 out of 52 out of 5     Points: 6

hi,
Static class:
A class can be declared static, indicating that it contains only static members. It is not possible to create instances of a static class using the new keyword. Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.

The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created.

Static classes are sealed and therefore cannot be inherited. Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.

Sealed Class:
when a class defined as sealed its not possible to inherit
its class and properties to the inherited class.Its also
applicable to the class properties.Even class defined as
public its banned to inherit the class.





 
#260602    Author: Ebenezer      Member Level: Silver      Member Rank: 0     Date: 08/Jul/2008   Rating: 2 out of 52 out of 5     Points: 0

Sealed cannt be inherit by other..

 
#260605    Author: Roopesh Babu Valluru      Member Level: Gold      Member Rank: 409     Date: 08/Jul/2008   Rating: 2 out of 52 out of 5     Points: 3

class which cannot be inherited is called sealed class....

class with atleast one method WITH OUT FUNCTIONALLITY is called as static class...it should be inherited and provide functionallity in derived class....

All The Best...


 
#260690    Author: chandramohan      Member Level: Gold      Member Rank: 218     Date: 08/Jul/2008   Rating: 2 out of 52 out of 5     Points: 1

Static class:
A class can be declared static, indicating that it contains only static members. It is not possible to create instances of a static class using the new keyword. Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.

The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added. The compiler will guarantee that instances of this class cannot be created.

Static classes are sealed and therefore cannot be inherited. Static classes cannot contain a constructor, although it is still possible to declare a static constructor to assign initial values or set up some static state.

Sealed Class:
when a class defined as sealed its not possible to inherit
its class and properties to the inherited class.Its also
applicable to the class properties.Even class defined as
public its banned to inherit the class.


 
#265950    Author: Ultimaterengan      Member Level: Gold      Member Rank: 10     Date: 18/Jul/2008   Rating: 2 out of 52 out of 5     Points: 1

Static classes are used when a class provides functionality that is not specific to any unique instance. Here are the features of static classes in C# 2.0.

Static classes can not be instantiated.
Static classes are sealed so they can not be inherited.
Only static members are allowed.
Static classes can only have static constructor to initialize static members.

Advantages

Compiler makes sure that no instance of static class is created. In previous version of C#, the constructor has to be marked private to avoid this from happening.

Also compiler makes sure that no instance members are declared within a static class.



Thanks & Regards
G.Renganathan
Nothing is mine ,Everything is yours!!!



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : saveandupdate using mysql
Previous : radio btn inside grid
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India