Tuesday, September 2, 2014

How to debug or execute C# program?

Step 1: Open Notepad and write the following c# code carefully.


using System;
 
namespace Chapter1
{
  class Program
   {
     static void Main(string[] args)
      {
        Console.WriteLine("This is my First C# Program");
      }
   }
}


Step 2: Now save this program as Chapter1.cs. You must choose All Files in save as type box.
Step 3: Go to Start > All Programs > Microsoft Visual Studio 2005 or 2008 > Visual Studio Tools > Visual Studio 2005 or 2008 Command Prompt.
Step 4: Set Path in command prompt where your Chapter1.cs file is saved. Here we are using D:/Csharp>
Step 5: Now compile your program by following command:
  csc Chapter1.cs


You will see some information like compiler version number and framework information. There is no error, so you won’t get any error.
Step 6: Now, it’s turn to C sharp program. Just write your file name without extension and hit enter.
  Chapter1
Step 7: You will get the This is my First C# Program as output.

Output