Compile and Run C# Program in Command Prompt

C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its .NET initiative led by Anders Hejlsberg. C# is part of .Net framework and is used for writing .Net applications.To run C# on your computer you must have installed "Microsoft.Net Framework".
If you dont have .Net installed on your system then download it from the link given below

http://www.microsoft.com/en-in/download/details.aspx?id=21

Now, step by step procedure to compile and execute C# programs is given below.

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



2. Click on "View advanced system settings" .
Note: If you are using Windows 8 then search "Control Panel" and then click "System" option in control panel.

3. System properties window will open.

4. Click on "Enviromment Variables".


5.  In the "User Variables" box (lower side), click "New" button.
Note: Don't change anything in System Variables as it will result in malfunctioning of some command prompt functions.

6.  In the "Variable name" write "Path" and in "Variable value" paste the following line
     
     C:\Windows\Microsoft.NET\Framework64\v3.5\




7. Click "OK".

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


//my first c# program.
using System;
​class kodestat
{
 public static void Main(String []args)
 {
        Console.WriteLine("Hello World!");
        Console.WriteLine("Welcome to Kodestat...");
 }
}
9. Create a folder named "kodestat" (or any other name which you like) on desktop and then save the file as kodestat.cs inside this folder.
Note: The file name should be your class name, ".cs" is c# program extension. If you are using notepad then Encoding should be "Unicode" as we are usind some symbols etc.



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

11. Click on "Open command window here".
Note: If you are using xp or later version then in command prompt type following code

cd desktop 

Hit "Enter" and then type

cd kodestat

12. Command window will open inside this folder.

13. Type 

csc kodestat.cs

and press enter.

14. Next type

kodestat

and press enter and you can see the output as

Hello World !





SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment