Studies show that good grammar leads to more promotions and higher salaries. Write with Grammarly

C# Error CS0132 – ‘constructor’ : a static constructor must be parameterless

C# Compiler Error

CS0132 – ‘constructor’ : a static constructor must be parameterless

Reason for the Error

You will receive this error when you define a static constructor with one or more parameters in C#.

Try compiling the below code snippet.

namespace DeveloperPublishNamespace
{
    public class DeveloperPublish
    {
        static DeveloperPublish(int param1)   
        {
        }
        public static void Main()
        {
            
        }
    }
}

In the above C# code snippet, we have defined a static constructor with one parameter and this results with the below error.

C# Error CS0132 – 'constructor' : a static constructor must be parameterless

Error CS0132 ‘DeveloperPublish.DeveloperPublish(int)’: a static constructor must be parameterless ConsoleApp1 C:\Users\Senthil\source\repos\ConsoleApp1\ConsoleApp1\Program.cs 5 Active

Solution

To fix the error code CS0132, ensure that the static constructor is parameter-less.