Understanding x++ vs ++x
Hi, i have this code, and i do not understand the output, i declare x=9, but it prints x=10, why? int x = 9; int y = ++x; int z = y++; Console.WriteLine("x = " + x); Console.WriteLine("y = " + y); Console.WriteLine("z = " + z); //Output: //x = 10 //y = 11 //z = 10 // BUT WHY!? ------------------------------------------------------------------------------------ int x = 9; int y = x++; int z = ++y; Console.WriteLine("x = {0}", x); Console.WriteLine("y = {0}", y); Console.WriteLine("z = {0}", z); //Output: //x = 10 //y = 10 //z = 10 // BUT WHY!?