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

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

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...