C# language feature:

  • Static classes

applies to

  • classes

benefit

  • Allows a safe and convienient way to declare class containing static methods that cannot be instantiated.

how to use

  • Declare class with static modifier.

example:

    public static class Static_Class_Circle_Example
    {
        public static double AreaFromRadius(double radius)
        {
            return 3.14*radius*radius;
        }
    }
    public class Use_of_Static_Class_Example
    {
        public void use_static_class_method(){
            // no need to declare and instantiate a variable of Static_Class_Circle_Example
            System.Console.WriteLine(Static_Class_Circle_Example.AreaFromRadius(5));
        }
    }