First program in C# with all details

 

 

1.  Program Structure Analysis:

// C# program to print Welcome to TechDevelopers Hindi.

using System;

namespace FirstProgram

{

class Program

{

static void Main(string[] args)

{

Console.WriteLine("Welcome to TechDevelopers Hindi");

Console.ReadKey();

}}}

 

1. NET Framework References:

Every .NET application takes the reference of the necessary .NET framework namespaces that it is planning to use with the using keyword, e.g., using System.Text.

2.  Namespace:

Declare the namespace for the current class using

the namespace keyword, e.g., namespace FirstProgram.

 

3.  Class:

class is the keyword which is used for the declaration of classes. Program is the user-defined name of the class. Every class extension in C# is .cs, like Program.cs

 

 

 

4. Static:

Static keyword tells us that this method is accessible without create the object of class.

5. Void:

Void keyword tells that this method will not return anything.

6. Main():

The Main() is a method of Program class is the entry point of the console application.

The execution of every C# program starts from the Main()          method. So it is mandatory for a C# program to have a Main() method for console application.

 

6. Arguments:

Arguments are passed into a method as parameters in C# and parameters could be anything as per needed and a method can be with or without parameters. i.e. string[] args.

 

7. Console.WriteLine():

WriteLine() is a method of the Console class defined in the System namespace. It is a static method, which is used to display a text on the console.

 

8.Console.ReadKey():

This is for the VS.NET Users. This makes the program wait for a key press and prevents the screen from running and closing quickly.

Note: Every line or statement in C# must end with a semicolon (;).

 

 

Comments

Popular posts from this blog

.NET Framework Introducton

CLR with advantages and architectures

Definition and features of C#.