SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Visual Basic 9: Standing Proud

Latest post 09-21-2005 10:17 PM by icelava. 16 replies.
  • 09-21-2005 9:41 PM In reply to

    Re: Visual Basic 9: Standing Proud

     icelava wrote:
    VB C#
            Console.Write("Enter first number: ")
            Dim first = Integer.Parse(Console.ReadLine())
            Console.Write("Enter second number: ")
            Dim second = Integer.Parse(Console.ReadLine())

            If (first <= second) Then
                Console.WriteLine("First number lesser or equal.")
            Else
                Console.WriteLine("Second number greater.")
            End If
                Console.Write("Enter first number: ");
                int first = int.Parse(Console.ReadLine());
                Console.Write("Enter second number: ");
                int second = int.Parse(Console.ReadLine());

                if (first <= second)
                    Console.WriteLine("First number lesser or equal.");
                else
                    Console.WriteLine("Second number greater.");

    Try
      Dim first as Integer
    and
      Dim second as Integer

    and check the IL code again. Smile [:)]

    In VB.Net, if you do not specify the type, you get the default Object type, which needs to be boxed. Recall in the earlier incarnations of VB, you have Variant.. In some sense, it is analogous.

    and you should see the boxing is gone.

  • 09-21-2005 10:17 PM In reply to

    Re: Visual Basic 9: Standing Proud

    Ah..... the joys of late type-binding. I remember having an "easy" programming experience the first time I started my development career with VB, then having a short tough period of cold turkey getting into the habit of explicit type casting when switching to C#.

    The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Page 2 of 2 (17 items) < Previous 1 2 | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems