Getting Started With Very First C# Program.

Creating a new Console Application in Visual Studio.

  • Open a Visual Studio in your system.(You can find it in the Start Menu Programs.)
  • You can create a new project in different ways
    1. Using classic method, Goto File -> New -> New Project.
    2. Using Quick Method, On Start Page Click on Create a New Project .
  • After Clicking the Create New Project, You will get a template window.
  • Select the Visual C# in side menu.
  • Select the Create new Console Application.
  • Name the Project (any name you want e.g. helloApp).
  • Select the Directory where you want to save it.
  • And Click Create button.

Writing Your First Code in C#.

  • After Creating a new project you will get the code like bellowed.
     using System;
     namespace helloApp
           {
                class Program
                 {
                      static void Main(string[] args)
                      {
                          //Here goes your code...
                      }
                 }
           }

  • You need to Write Console.WriteLine("Whatever You Want to Print on console."); between the braces below the Main() method.
  • Short Cut for Writing Console.WriteLine is just type 'cw' and press TAB button twice.

Executing the Program.

  • To Execute the written program Press F5 button on your keyboard.
  • If you Pressed F5 console will run for the only few milliseconds to halt the Console until any key pressed you need to Write Console.ReadKey(); below your written Code.
  • OR you Can just Press Ctrl+F5.
  • It will halt the console window until you press any key. 

Comments

Popular posts from this blog

Code First Approach with Entity Framework

Getting Ready for Python Development on Ubuntu using VSCode

Designing Model class with validation in ASP.NET MVC