Home > .NET Framework > VB.NET and the ‘/’ operator

VB.NET and the ‘/’ operator

Program 1: What is the output?

Sub Main()

Try

Dim a As Integer

Dim b As Integer

Dim c As Integer

a = 1

b = 0

c = a / b

Catch ex As DivideByZeroException

Console.WriteLine("Divide by zero error!")

Catch oex As OverflowException

Console.WriteLine("Overflow error!")

End Try

Console.ReadLine()

End Sub

Program 2: What is the output?

Sub Main()

Try

Dim a As Decimal

Dim b As Integer

Dim c As Integer

a = 1

b = 0

c = a / b

Catch ex As DivideByZeroException

Console.WriteLine("Divide by zero error!")

Catch oex As OverflowException

Console.WriteLine("Overflow error!")

End Try

Console.ReadLine()

End Sub

Surprise, I was really bounced by this one. Via buddhike’s blog

Advertisements
Categories: .NET Framework
  1. Utham
    July 26, 2006 at 5:54 pm

    interesting
     
    no idea why its soo
     
    ???

  2. Sendhil Kumar
    August 3, 2006 at 1:26 pm

    I was also stumped for a moment. Check this http://msdn2.microsoft.com/en-us/library/25bswc76.aspx
     
     

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s