TransUniv

Friday, January 23, 2015

How to execute C# programs in cmd

                  If you want to compile and run C# programs via cmd (Command Prompt) instead of using Visual Studio C# Express IDE then follow the following simple steps .




1. Find Microsoft.NET installation path.


        You might know the Microsoft.Net is the framework to make windows based applications with various programming languages. This .Net path is installed in your systems windows directory.
Just copy this path. "C:\Windows\Microsoft.NET\Framework\v4.0.30319". The version number (v4.0.30319) may vary based on your .Net framework version.



2. Change your path in cmd.


        Open the command prompt and change the directory to where the c# source codes are saved. Check out following screenshot.



3. Set path to .Net Framework.


          Now set .Net framework's path to your working directory to compile and run the programs like shown in the screenshot below.



4. Compile and Run


       Now you are ready to compile and run your programs.


  • To compile the program use "csc File_name.cs" (Without Quotes) for example "csc helloworld.cs".
  • To run the program use "File_name" (Without Quotes) for example "helloworld".
     


  Hope it was useful to you.



Today's Quote:

                       "Be the change you want to see in the world".
  
                                                                                            - Mahatma Gandhi.



        

4 comments: