TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C# Coding Standard
Search

Rule:  7@102Checked automatically with code checker

Synopsis:Prevent instantiation of a class if it contains only static members
Language:C#
Severity Level:5
Category:Object oriented


Description:

If a class only contains static members there is no use to instantiate it. The way to prevent instantation is to mark the class as static.

Note that a static class can't be inherited from because there is no use for it (children are only accessible via class names not via instances). So if you have a class with only static methods and it has children, then it is recommended to make a utility class instead.



Literature References:
StackOverflow should a class with only static methods be static?
StackOverflow why can't I inherit from a static class?