Feature of a Static Class

In C# we use Static classes. Static class has the below features,  
  • We cannot create an instance of static class
  • Static class can have only static members.
  • Member of the Static class can be accessed by class name itself because it is not object related
  • Static class cannot be inherited.
  • Static class contains only static constructors.
  • Static class cannot have instance constructors.

System.Math is an example of static class when we call the method of Math classe. We don’t use Math object, we directly use Math.Add().

We need a static class to create extension methods.

The utility classes in an application are wehre we write static classes to put common functionality and call those utilities without creating objects.

This was all about static class in C#.Thanks for reading.

Ebook Download
View all
Learn
View all