Static

What is output of below code?

public class StaticTest
{
   public static int sTest;

   public StaticTest()
   {
      if (sTest == 0)
           sTest = 5;         
   }

   static StaticTest()
   {
       if (sTest == 0)
            sTest = 10;           
   }

   public void Print()
   {
       if (sTest == 5)
            sTest = 6;                                   
    
    Console.WriteLine("Static Value : " + sTest);
   } 
}

public void Main()
{
   var t = new StaticTest();
   t.Print();
}

Leave a Reply

Your email address will not be published. Required fields are marked *