Top "Static-constructor" questions

A static constructor is used to initialize any static data, or to perform a particular action that needs to be performed once only.

What is the use of static constructors?

Please explain to me the use of static constructor. Why and when would we create a static constructor and is …

c# constructor static-constructor
static constructors in C++? I need to initialize private static objects

I want to have a class with a private static data member (a vector that contains all the characters a-z). …

c++ static private initializer static-constructor
How to pass parameter to static class constructor?

I have a static class with a static constructor. I need to pass a parameter somehow to this static class …

c# class static static-classes static-constructor
System.TypeInitializationException: The type initializer for 'Tips' threw an exception

I am trying to access the values of a static list. However when I try to do so this exception …

c# list windows-phone-7 static-constructor
How can I run a static constructor?

I'd like to execute the static constructor of a class (i.e. I want to "load" the class) without creating …

c# .net static-constructor
Explicitly call static constructor

I want to write unit test for below class. If name is other than "MyEntity" then mgr should be blank. …

c# mstest system.reflection static-constructor
Passing static parameters to a class

As far as I know you can can't pass parameters to a static constructor in C#. However I do have 2 …

c# static-members static-constructor
Pass argument to a static constructor in Java?

I'm trying to initialize a static class, with an argument, and then run some more static code in that class. …

java static constructor static-constructor
Private vs Static constructors in .Net

I searched for this a lot, but none of the answers are clear (at-least for me!). Now I'm putting this …

c# .net static-constructor private-constructor
static readonly field initializer vs static constructor initialization

Below are two different ways to initialize static readonly fields. Is there a difference between the two approaches? If yes, …

c# c#-3.0 c#-2.0 initializer static-constructor