I’ll need to reflect on that

I do most of my programming these days in C#, though I have ended up learning a little Visual Basic over the years. It never ceases to amaze me how IL manages to support two languages with very different features.

I was surprised to find out the other day that VB allows you to branch from an exception handler back into the code that the handler is guarding, allowing you to write an infinite loop of the form.

Sub Main()
      Throw New Exception()
   Catch ex As Exception
    GoTo restart
  End Try
End Sub

C# doesn’t allow that kind of branching.

static void Main(string[] args)
    throw new Exception();
  catch (Exception)
    goto Restart; // Invalid

This entry was posted in Computers and Internet. Bookmark the permalink.

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