Monday, September 13, 2010

Getting started with Console Application

How to start with Console application


  • Click file menu select New project.
  • In New project window select Visual C# in Project types section and Console Application in Templates Section.
  • Change Name field (Desired Name).
  • Click OK
Then you see a default Code as shown below
//Pre-defined Namespaces for our program explained later in the next postusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//We can have group of Namespaces in one .cs file
namespace ConsoleApplication2 
{
    class Program
    {
      //Main function.. the word indicates "Main". Execution of .cs file starts with Main() function/Method
        static void Main(string[] args)
        {
        }
    }
}
Lets start with first application in console application
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //Display some text or write some values like Output values we use Write/Writeline
            Console.WriteLine("Welcome to CoolTuts");
            //After execution out Output window. we can call black screen or output window. It stops at this point
            Console.ReadKey();
        }
    }
}
OUTPUT
Welcome to CoolTuts

No comments:

Post a Comment