Suppose I have the following class:
class Dummy
{
public static Dictionary<int, int> dict = new Dictionary<int, int>(); // (1)
static Dummy() // (2)
{
dict.Add(1, 100);
dict.Add(2, 200);
}
}
This type will be accessed by multiple threads. When will the (1) and (2) be executed? Will they be executed for each thread? Is it possible that a key duplication exception will occur?