A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated. You access the members of a static class by using the class name itself. For example, if you have a static class that is named UtilityClass that has a public method named MethodA,:
UtilityClass.MethodA();
Use of static class:
A static class can be used as a convenient container for sets of methods that just operate on input parameters and do not have to get or set any internal instance fields. For example, the static System.Math class contains methods that perform mathematical operations, without any requirement to store or retrieve data that is unique to a particular instance of the Math class.
double dub = -3.14;
Console.WriteLine(Math.Abs(dub));
Console.WriteLine(Math.Floor(dub));
Console.WriteLine(Math.Round(Math.Abs(dub)));
// Output:
// 3.14
// -4
// 3
A static constructor is only called one time, and a static class remains in memory for the lifetime of the application domain in which your program resides.
Main features of a static class:
• Contains only static members.
• Cannot be instantiated.
• Is sealed.
• Cannot contain Instance Constructors.