Click here to Skip to main content
15,920,687 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I know What Static class is but what is the advantage of having static class
Does it has any relation to speed of application(execution time)......
Posted

1 solution

Static classes are loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
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.
Use a static class to contain methods that are not associated with a particular object. For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. You could use a static class to hold those methods.
The main features of a static class are:
• They only contain static members.
• They cannot be instantiated.
• They are sealed.
• They cannot contain Instance Constructors .
Creating a static class is therefore much the same as creating a class that contains only static members and a private constructor. A private constructor prevents the class from being instantiated.
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.

For more See this Static Classes and Static Class Members
 
Share this answer
 
Comments
Vishal Pand3y 22-Nov-13 1:53am    
@BillWoodruff First I have Given Link of the Source
and Second i haven't exactly copy paste this from MSDN this is Copied From my notes Which i have created by googling several sites .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900