Monday, April 29, 2013

How to Compile and Run C# Program in Command Prompt of Windows 7 without any software

Without installing any software, we can compile and run C# program in Command Prompt of Windows 7. Step by step procedure is given below:

1. Type "Advance system settings" in windows start menu.

2. Click on "View advanced system settings"


3. System properties window will open.

4. Click on "Enviromment Variables".


5. In the "System Variables" box (lower side), first select "Path" and then click "Edit" button.


6. At the end of the "Variable value", first put a semicolon ";" (with out invited comma) and then paste the following line:

C:\Windows\Microsoft.NET\Framework64\v3.5\


7. Click "Ok".

8. Now open notepad and write your first C# program.

// First program in C#.
using System;
namespace HelloWorld
{
    class HelloCS
    {
        static void Main()
        {
            Console.WriteLine("Hello World !");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}

9. Create a folder named "test" on desktop and then save the file as HelloCS.cs inside this folder.


10. Now go to desktop and Shift+RIght Click on the "test" folder.

11. Click on "Open command window here".

12. Command window will open inside this folder.

13. Type

csc HelloCS.cs

and press enter.

14. Next type

HelloCS

and press enter and you can see the output as

Hello World !



No comments:

Post a Comment