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.

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...