नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
| Property | Value |
|---|---|
| Rule ID | CA1053 |
| Title | Static holder types should not have default constructors |
| Category | Design |
| Fix is breaking or non-breaking | Breaking |
| Enabled by default in .NET 10 | No |
Note
Rule CA1053 only applies to legacy Visual Studio code analysis. In the .NET code-quality analyzers, it's combined into rule CA1052: Static holder types should be Static or NotInheritable.
Cause
A public or nested public type declares only static members and has a default constructor.
Rule description
The default constructor is unnecessary because calling static members does not require an instance of the type. Also, because the type does not have non-static members, creating an instance does not provide access to any of the type's members.
How to fix violations
To fix a violation of this rule, remove the default constructor.
When to suppress warnings
Do not suppress a warning from this rule. The presence of the default constructor suggests that the type is not a static type.