Reader Level:

Static class in C#

By Hirendra Sisodiya on Jul 28, 2010
In this article you will learn how to use Static classes in c#.

HTML clipboard

C# provides the important feature to create static classes, there are two main features of a static class, one is no object of static class can be created and another is, a static class must contain only static members, then it is important that what is the main benefit to create a static class, the main benefit of making static class, we do not need to make any instance of this class ,all members can be accessible with its own name.


A static class is created by using keyword 'Static' as shown here:

Static class Clasname


One more thing that is notable-within static class, all members must be explicitly specified as static, static class does not automatically make its members static. Static class can contain a collection of static methods.


using System;


static class Shape


    public static double GetArea(double Width, double height)


        return Width * Height;




class Ractangle


    private void GetRactangleArea()


        Double Area;

        Area = Shape.GetArea(10, 5);



Shape is static class, it contain staic function GetArea.Ractangle is other class and with in GetArea function can be access without creating instace of Class Shape.

Although a static class cannot have an instance constructor, it can have a static constructor.

Hirendra Sisodiya
Hirendra Sisodiya

My main area of experience has been application development. I have worked primarily in the domain of banking and financial services etc. My technological forte is Microsoft Technologies especially VB 6.0, Dot Net (Visua... Read more



JetBrains ReSharper Ultimate
.NET code analysis, refactorings, navigation, unit testing, code coverage and profiling in Visual Studio, a bonus for C++ devs, bundled at 50% off.

Trending up