In Visual Studio 2010 SP1, if we build the application in the x64/Any CPU mode, we see that the static variable initialization does not happen under the debug mode.
If we create a console application using the following code snippet and putting the break point on the "private static bool publishEvent = true", we see the value of the static variable does not change, while stepping into the code. The value of the static variable remains uninitialized, in this case, false.
The expected behavior is, the value of publishEvent becomes true.
class Test
{
private static bool publishEvent = true;
public Test()
{
Console.WriteLine("{0}", publishEvent);
}
}
class Program
{
static void Main(string[] args)
{
Test varT = new Test();
Console.ReadLine();
}
}
If we create a console application using the following code snippet and putting the break point on the "private static bool publishEvent = true", we see the value of the static variable does not change, while stepping into the code. The value of the static variable remains uninitialized, in this case, false.
The expected behavior is, the value of publishEvent becomes true.
class Test
{
private static bool publishEvent = true;
public Test()
{
Console.WriteLine("{0}", publishEvent);
}
}
class Program
{
static void Main(string[] args)
{
Test varT = new Test();
Console.ReadLine();
}
}