How to pass parameter to static class constructor?

Don’t use a static constructor, but a static initialization method:

public class A
{
    private static string ParamA { get; set; }

    public static void Init(string paramA)
    {
        ParamA = paramA;
    }
}

In C#, static constructors are parameterless, and there’re few approaches to overcome this limitation. One is what I’ve suggested you above.

Leave a Comment