Static holder types should not have constructors
.NET Framework 2.0
| TypeName | StaticHolderTypesShouldNotHaveConstructors |
| CheckId | CA1053 |
| Category | Microsoft.Design |
| Breaking Change | Breaking |
The following example shows a type that violates this rule. Note that there is no default constructor in the source code. When this code is compiled into an assembly, the C# compiler will insert a default constructor, which will violate this rule. To correct this, declare a private constructor.
using System; namespace DesignLibrary { public class NoInstancesNeeded { // Violates rule: StaticHolderTypesShouldNotHaveConstructors. // Uncomment the following line to correct the violation. // private NoInstancesNeeded() {} public static void Method1() {} public static void Method2() {} } }
Note