Problem Statement
You need to use he csc.exe (C# command line compiler) to compile the Csharp program from Command prompt.
Solution
Use the command prompt and use the csc.exe to compile and run the program from the command prompt.
Follow the below steps to compile and run the C# program from command prompt.
1. Type the program in the notepad and save it as hello.cs under D:\kedo folder.
Below is the sample code that can be in the notepad file.
using System; public class Program { public static void Main(string [] args) { Console.WriteLine("Hello world"); } }
2. Compile the program by typing the following
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc hello.cs
Here , csc is the name of the csharp file which is usually found in the path
C:\Windows\Microsoft.NET\Framework\<.NET Framework Version>
3. Once the compilation is successful , you can enter the name of the file with the .exe extension
Leave a Reply