CSharp - What is the output: Overflow constant expressions?

Question

What is the output of the following code?

using System;
class MainClass
{
   public static void Main(string[] args)
   {
       int x = int.MaxValue + 1;
       Console.WriteLine(x);

   }
}


Click to view the answer

int x = int.MaxValue + 1; // Compile-time error

Note

Regardless of the /checked compiler switch, expressions evaluated at compile time are always overflow-checked.

You can turn off the check by using the unchecked operator.

int y = unchecked (int.MaxValue + 1);   // No errors