I ran a program in .Net 3.5 using C# which works fine
try
{
int i = 2147483647;
Console.WriteLine((i * 100 / i).ToString());
Console.ReadLine();
}
catch (Exception)
{
throw;
}
When I run this program in C#, I don't get an exception (it outputs "0"). But when I run this program in VB.Net it results in "Arithmetic operation resulted in an overflow" exception
Try
Dim i As Integer = 2147483647
Console.WriteLine((i * 100 / i).ToString())
Console.ReadLine()
Catch ex As Exception
Throw
End Try
Why the different behavior between these two languages?
(i * 100) / ivs.i * (100 / i)...(i * 100) / iis just100.