C Sharp static class

C# static class

Similar to the normal class is the C# static class. However, it can’t be instantiated. Having only static members, it also provides the guarantee that instance of the static class can’t be created. It is sealed and can’t contain instance constructors.

Example:

using System;  
   public sttic class Example  
    {  
        public static float PI=3.14f;   
        public static int square(int x){return x*x;} 
        public static int sum(int x, int y){return x+y;}  
    }  
   class Display{  
       public static void Main(string[] args)  
        {  
            Console.WriteLine("PI = "+Example.PI);  
            Console.WriteLine("Square of 5 = " + Example.square(5));  
            Console.WriteLine("Sum of 5 and 5 = " + Example.sum(5,5));  
        }  
    }

Output:

Explanation:

In the above example, the static class contains a static field and a static method.