find and solve ||
Please wait.....

Static Class In C#

In c# programming language is allowed to create a static class, by using the static keyword. A static class can only contain static data members, static methods.

Points to remember for C# static class

  • C# static class contains only static members.
  • C# static class cannot be instantiated.
  • C# static class is sealed.
  • C# static class cannot contain instance constructors.

C# static class example

   using System;  
   public static class Example
    {         public static float PI=3.14f;
        public static int cube(int n){return n*n*n;}
  public class AnotherClasExample{
       public static void Main(string[] args)         {
            Console.WriteLine("Value of PI is: "+Example.PI);
            Console.WriteLine("Cube of 3 is: " + Example.cube(3));


Value of PI is: 3.14

Cube of 3 is: 27