Static class

Author posted by Jitendra on Posted on under category Categories c# with Leave a comment on Static class

Example of Static Class, its usage and benefits

C# introduced a new feature known as Static Class.

A class which has only Static Methods is known as Static Class.

Benefit of Static Class:

  • Object of static class cannot be created.
  • All methods and members can be accessed by class Name.

Note :

  • All methods of static class must be specified explicitly by keyword static.
  • Static class cannot have instance constructor but it can have Static Constructor.


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);


In above Example Shape is Static class and contains static method named GetArea().

And other class (Rectangle) access the GetArea() method without creating the instance of class Shape.

Related posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.