Visual Basic 10 Is One Step Closer to Being C#

This past week, I was given twenty minutes to present at the Indianapolis .NET Developers Association (IndyNDA.org) on some of the new features in the Microsoft programming languages that are coming in the next releases. I was also supposed to talk on some of the stuff coming in Visual Studio "2010." It is interesting to note that although I had twenty minutes that could be stretched to thirty, the same topics were quickly overviewed at the Microsoft PDC over the course of more than five hours. 

 

Needless to say, I left out nearly everything!

 

What I didn't leave out were a couple of the simplest features coming in C# 4 and Visual Basic 10. I'll cover those same features in this and my next few blog entries.

 

One of the items that received the biggest applause for Microsoft was in my Visual Basic 10 demo. With Visual Basic 10, the VB team has spent a lot of effort doing something that seems very simple. Consider the following Visual Basic code:

 

Module Module1

    Sub Main()

        Dim scores() AsInteger = {10, 20, 30, 40, _

                                   50, 60, 70, 80, _

                                   90, 100, 3, 4}

        ForEach score In scores

            Console.WriteLine("The next number is.... {0}", _

                              score)

        Next

    EndSub

EndModule

 

This same code could be formatted in a variety of ways using various spacing. With Visual Basic, however, you've always had to remember to include the space-underscores at the end of each lineto indicate that the code continues to the next.

 

With Visual Basic 10, the need for the line continuation character is no more! In truth, there are instances where you might still need to use them; however, in almost all common coding situations, you don't need them. That means that the following code is now valid Visual Basic 10 code:

 

Module Module1

    Sub Main()

        Dim scores() AsInteger = {10, 20, 30, 40,

                                   50, 60, 70, 80,

                                   90, 100, 3, 4}

        ForEach score In scores

            Console.WriteLine("The next number is.... {0}",

                              score)

        Next

    EndSub

EndModule

 

Now, all you have to do is add a "quote-semicolon" and you are practically writing C#! 

 

Module Module1

    Sub Main()

        Dim scores() AsInteger = {10, 20, 30, 40,

                                   50, 60, 70, 80,

                                   90, 100, 3, 4} ';

        ForEach score In scores

            Console.WriteLine("The next number is.... {0}",

                              score) ';

        Next ';

    EndSub

EndModule

 



Blog Categories

Blog Archives

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds