|
If a class contains nothing but static methods and properties, the class itself become static. A static class is functionally the same as creating a class with a private static constructor. An instance of the class can never be created. By using the static keyword, the compiler can help by checking that instance members are never accedentally added to the class. If they are added, the compiler error will happens. This can help guarantee that an instance is never created. The syntax for static class looks like this static class StaticUtilities { public static void HelperMethod(); { } } An object of type StaticUtilities not needed to call the HelperMethod(). The type name is used to make the call: StaticUtilities.HelperMethod();
|