Compilation and execution of a C# app written in a notepad can be done using a command prompt but not VS.NET.
It is recommended not to use windows command prompt (cmd). Instead of that we can use ” Visual Studiocommand prompt” which is a free tool available along with .NET framework.
To know the reason, type CSC (C# compiler) within your windows cmd prompt. You will get the assistance as “csc is not recognized……….”, since no path is set to C# compiler. So we need to explicitly set path to C# compiler (like how we set path to java compiler) to compile and run C# app in windows cmd prompt, but why to do so when Microsoft provides us with a tool (VS cmd prompt) which has an ability to recognize the C# compiler or any .NET compatible language compilers.
So, directly go to VS cmd prompt which is present within VS tools from Start-->MS VS 2008/2005. Now go to your current working directory by using cd command and type csc Basic.cs shown as follows:
As soon as you press ‘enter’, Basic .exe file (called as assembly) will be generated - which includes compiled code (IL code) plus some other information (metadata + resources if any) regarding your file. This is shown as follows: (note: Type dir within the command line to view .exe file).
Now type your C# filename within the VS cmd prompt to run or execute your app - shown as follows: (this will display the program output)
It is recommended not to use windows command prompt (cmd). Instead of that we can use ” Visual Studio
To know the reason, type CSC (C# compiler) within your windows cmd prompt. You will get the assistance as “csc is not recognized……….”, since no path is set to C# compiler. So we need to explicitly set path to C# compiler (like how we set path to java compiler) to compile and run C# app in windows cmd prompt, but why to do so when Microsoft provides us with a tool (VS cmd prompt) which has an ability to recognize the C# compiler or any .NET compatible language compilers.
So, directly go to VS cmd prompt which is present within VS tools from Start-->MS VS 2008/2005. Now go to your current working directory by using cd command and type csc Basic.cs shown as follows:
As soon as you press ‘enter’, Basic .exe file (called as assembly) will be generated - which includes compiled code (IL code) plus some other information (metadata + resources if any) regarding your file. This is shown as follows: (note: Type dir within the command line to view .exe file).
Now type your C# filename within the VS cmd prompt to run or execute your app - shown as follows: (this will display the program output)
1/29/2010 05:13:00 PM |
Category:
Basic C# Programming...
|
