Sample 1
int a = Int32.MinValue;
int b = -a;
Console.WriteLine("a={0}",a);
Console.WriteLine("b={0}", b);
Result
a=-2147483648
b=-2147483648
Sample 2
int a = Int32.MinValue;
int b = a-1;
Console.WriteLine("a={0}",a);
Console.WriteLine("b={0}", b);
Result
a=-2147483648
b=2147483647
In two samples: why doesn't it throw overflow exception. When I tried these samples in java environment, I got same results. Is there anyone who can explain this situation?