0

In the following code, if I put a breakpoint in the static constructor of Class3, i don't see the constructor of Class1 in the visual studio stack trace. If I replace the line var test = Class2.c3 with var test = new Class2() I see it. Why is that ?

stacktrace

static void Main(string[] args)
{
  var c1 = new Class1();
}

class Class1
{
   public Class1()
   {
      var test = Class2.c3;
   }
}

class Class2
{
   public static Class3 c3 = new Class3();

}

class Class3
{
   static Class3()
   {
     Console.WriteLine("test");
   }
}

0 Answers0