The requested page is not available for the requested platform. You are viewing the content for Default platform.

Static constructors must be parameterless

CodeRush Classic shows the Static constructors must be parameterless code issue if a static constructor has parameters.

Fix

Remove the parameters from the static constructor declaration.

Purpose

Highlights the static constructor declarations, which would cause the A static constructor must be parameterless compilation error.

Example

public static class MyClass
{
    static MyClass(string text)
    {
        Text = text;
    }
    public static string Text { get; set; }
}

Fix:

public static class MyClass
{
    static MyClass()
    {
        Text = String.Empty;
    }
    public static string Text { get; set; }
}