News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

VB.NET and C# Comparison

Started by dhilipkumar, Sep 12, 2008, 04:15 PM

Previous topic - Next topic

dhilipkumar

 
                                                       compare syntax of VB.Net & C#

Program Structure:

                                                                       VB.Net

Imports System

Namespace Hello
   Class HelloWorld
      Overloads Shared Sub Main(ByVal args() As String)
         Dim name As String = "VB.NET"

         'See if an argument was passed from the command line
          If args.Length = 1 Then name = args(0)

          Console.WriteLine("Hello, " & name & "!")
      End Sub
   End Class
End Namespace



                                                           C#

using System;

namespace Hello {
   public class HelloWorld {
      public static void Main(string[] args) {
         string name = "C#";

         // See if an argument was passed from the command line
         if (args.Length == 1)
            name = args[0];

         Console.WriteLine("Hello, " + name + "!");
      }
   }
}

dhilipkumar

                                                                        Comments                             


        VB.Net

' Single line only
REM Single line only
''' <summary>XML comments</summary>
   

         C#

                                                                   

// Single line
/* Multiple
    line  */
/// <summary>XML comments on single line</summary>
/** <summary>XML comments on multiple lines</summary> */



                                                                      Constants
          VB.Net   


Const MAX_STUDENTS As Integer = 25

' Can set to a const or var; may be initialized in a constructor
ReadOnly MIN_DIAMETER As Single = 4.93



          C#
                                                                                       

   const int MAX_STUDENTS = 25;

// Can set to a const or var; may be initialized in a constructor
readonly float MIN_DIAMETER = 4.93f;