Friday, September 2, 2011

Static Class

Static class used to define the information that is object independent like company info. Static class contain only static methods and properties. Instance constructor can not be created inside static class. Although a static constructor can be defined there.

Properties of static class

1) Static class are sealed they can not be inherited since there is no constructor. Like a class which contain a private constructor.
2) They can not be instantiated.
3)They are loaded when program or namespace containing the static class load.
4) They can not have non static methods or variables.
5) They can have only static constructor if needed.
6) Benefit of using static class, compiler guarantee this thing that class does not have any instance.
7) Static class make implementation simple and faster since there is no object needed to call the methods. A good example of static class is Math class that contain all math functions like sin,cosine.

No comments:

Followers

Link