C# Compiler Error
CS0515 – ‘function’ : access modifiers are not allowed on static constructors
Reason for the Error
You’ll get this error in your C# code when you have specified the access modifiers for the static constructors.
For example, let’s try to compile the below C# code snippet.
using System;
namespace DeveloperPublishNamespace
{
public class BaseClass
{
public static BaseClass()
{
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("No Error");
}
}
}You’ll receive the error code CS0515 because the class BaseClass has a static constructor and has the public access modifier specified for it.
Error CS0515 ‘BaseClass.BaseClass()’: access modifiers are not allowed on static constructors DeveloperPublish C:\Users\Senthil\source\repos\ConsoleApp4\ConsoleApp4\Program.cs 6 Active

Solution
In C#, you cannot have the access modifiers for the static constructor. To fix the error code CS0515, you will need to remove the access modifier for the static constructor.