Friday, October 26, 2007

Program Structure in vb.net & c# language

Program Structure

In vb.net $ c# language program structure are differ. Example of program structure in vb.net $ c# language.

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 + "!");
}
}
}

--------------------------------------------------------------------------------------------------

Note: This code applicable for both desktop and web application.

--------------------------------------------------------------------------------------------------

No comments: