Saturday, May 8, 2010

Using the Command prompt to run C# program

For those of us who had gone on the fast track to learn C# (remember I was into java before the leap to .NET) Visual Studio IDE does a great job in encapsulating the details. For a beginner it just looks great, just write your code, hit F5 (or) run. You are done! But as you move on you begin to wonder how do you do it the old fashioned way (Command Line)?

That's exactly what I discovered learning C# 4.0. You have this tool called csc.exe (like javac), Go to your Visual Studio command prompt, navigate to the folder that has you program and do this:

> csc.exe yourprogramname.cs

This compliles your code and generates an exe. You can run your code using:
> youprogramname.exe

Replace yourprogramname with the name of your program.

0 comments: