R
Raj
int a = int.MaxValue;
int b = int.MaxValue-1;
Console.WriteLine("Before Swapping");
Console.WriteLine("a={0} b={1}", a, b);
try
{
a = a+b;
Console.WriteLine("a+b=", a);
b = a - b;
a = a - b;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("After Swapping");
Console.WriteLine("a={0} b={1}", a, b);
a=a+b becomes -3, justify!
Why is it not throwing any numeric overflow error?
If i give a=int.MaxValue+1 i get compile time error: overflow, but is the
CLR not bothered about run time overflow? or when will i get runtime numeric
overflow?
Pl. explain
int b = int.MaxValue-1;
Console.WriteLine("Before Swapping");
Console.WriteLine("a={0} b={1}", a, b);
try
{
a = a+b;
Console.WriteLine("a+b=", a);
b = a - b;
a = a - b;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("After Swapping");
Console.WriteLine("a={0} b={1}", a, b);
a=a+b becomes -3, justify!
Why is it not throwing any numeric overflow error?
If i give a=int.MaxValue+1 i get compile time error: overflow, but is the
CLR not bothered about run time overflow? or when will i get runtime numeric
overflow?
Pl. explain