C#

C# (Pronounced C Sharp) is a simple, Object Oriented Programming language. C# syntax is very much similar to C, C++ and Java.

Example:

// File name is —> Hello1.cs

using System;

public class Hello1
{
public static void Main()
{
Console.WriteLine(“Hello, World!”);
}
}

The Main method is the entry point of a C# console application or windows application. That is why Main must be static. Main can either have a void or int return type.

Example:

using System;

class TestClass

{

static void Main(string[] args)

{

// Display the number of command line arguments

Console.WriteLine(args.Length);

}

}

Main method can be declared with or without a string[] parameter that contains command-line arguments.

There can only be one entry point in a C# program. If you have more than one class that has a Main method, you must compile your program with the /main compiler option to specify which Main method to use as the entry point.

Syntax:

/main : class

Advertisements

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