Compilation and Execution of a C# Program

CsharpProgrammingServer Side Programming

To compile and execute a program in C#, you just need to click the Run button or press F5 key to execute the project in Microsoft Visual Studio IDE.

Compile a C# program by using the command-line instead of the Microsoft Visual Studio IDE −

  • Open a text editor and add the above-mentioned code.

  • Save the file as helloworld.cs

  • Open the command prompt tool and go to the directory where you saved the file.

  • Type csc helloworld.cs and press enter to compile your code.

  • If there are no errors in your code, the command prompt takes you to the next line and generates helloworld.exe executable file.

  • Type helloworld to execute your program.

  • You can see the output Hello World printed on the screen.

You can also use C# online compiler to execute a program in C#.

raja
Published on 17-Sep-2018 08:02:11
Advertisements