If at first you don't succeed, call it version 1.0

Contact Me

Sarvesh Kushwaha
Email : sarveshkushwaha@outlook.com

Total Pageviews

Powered by Blogger.

Google+ Followers

Friday, 11 April 2014

C# Command Line Compiler (CSC.EXE)

What is CSC.EXE ? 
Command line compiler takes C# code as input and transforms code to MSIL/CIL (Microsoft intermediate language/Common intermediate language).CSC.exe produces .dll (dynamic link library) and .exe (executable) files.

CSC.exe comes with .net framework.you can install it standalone too.which is in :

c:\Windows\Microsoft.Net\Framework\v4.0.30319{version installed on your computer}\csc.exe

How to Compile C# programs using CSC.exe (Without using Visual Studio) ?

Step 1:

Create a program first -> myprogram.cs (name is upto you :P) , so we can compile that using CSC.EXE .
I have created a program containing simple code :

using System;

public class myprogram
  static void Main()
  Console.WriteLine("I hate hello world");

Step 2:

  • Open the command prompt
  • Reach at the palace where is your program file exists
  • Locate the CSC (C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe )
  • Give input to CSC (C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe  myprogram.cs)
  • .exe will be generated ;) :) 

Step 3:

Like indian movies there is happy ending .. A myprogram.exe is generated on my desktop :) .Execute that exe using CMD to see the desired result :

YAY WE WON :P :) .Thats all what CSC.exe do for us .When we compile using visual studio its just use the same process we have done, behind the scene .


1 comment:

  1. get video tutorial on how to compile C# program using command prompt