Don’t have Visual Studio? Don’t worry. You can compile C# in a command prompt as long as you have the Microsoft .NET Framework installed. The program used to compile C# is csc.exe and is located at C:\Windows\Microsoft.NET\Framework64\v4.* on my installation (your location may vary slightly).

  1. Add the path to csc.exe your PATH environment variable.
  2. Open a command prompt and navigate to the directory where your source code is stored.
  3. Execute csc HelloWorld.cs to compile.
  4. Execute HelloWorld.exe to run the program.