C# > Introduction

Simple console application in C#

How to write a basic C# console application?


For writing the basic program in C# we can use below method.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Helloworldapplication
{
    class helloworld
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello world");
            Console.ReadKey();
        }
    }
}

The first line of program using system; using keyword is used to include system namspace in the program, The program has multiple using statements.

Next is the namespace declaration; namespace is defined as collection of classes. namespace helloworldapplication contains class.

The next line is class declaration, The class helloworld defines method where the program uses.

The next line is main method, the main method defines the class what is to be executed.

The next line is console.writeline which is used to print the value in the output. which prints the value as Helloworld.

The next line is console.readkey() which is used the next character.

  

output:

 Views: 1159 | Post Order: 4



Write for us