Technology Inside Out!

Index ¦ Archives ¦ Atom ¦ RSS

C# Tutorial : Compiling C# Programmes using Notepad

About C#

C# is a multi-paradigm object oriented language developed by Mircrosoft in the year 2000. C# has its major implementations in dotNet framework, Mono, DotGNU. In this tutorial we will print a simple line "" using a notepad and C# command line compiler.

In order to continue with the C# tutorial you will need the latest version of .NET Framework SDK installed on your machine. You can download latest version of .NET Framework here.

First of all you need to create a folder where you can save your C# programme, you can also save the file on Desktop but its always a good habit to keep your files organized, so I am creating a folder named TheGeekyWay in the C: drive.

Remember : C# is a case sensitive language. So everything should be same while writing the below code, any syntactical changes will bring down an error in compiling.

So here is the following C# code (don't worry the code will be explained in detail in next tutorial, for now we just focus on how to compile and run a c# code in command prompt)

public class TheGeekyWay
      public static void Main()
           System.Console.WriteLine("Welcome to");

Next step is to go to start button and type cmd and run as administrator. The reason using cmd is that many .NET tools can be used or scripted using DOS batch files.

Now in cmd type the following lines in cmd and reach to the directory of Framework. The reason for showing the directory is to know the recent version of C# compiler.

C# Tutorial : To run C# programme using Notepad Image 1

now next step is to go in the directory of your latest .NET version, for me its v4.0.30319, so we use the following command line to go in the latest .NET folder directory.

cd v4.0.30319

you can also visit the following code to view all the help related to C# compiler, remember to type the code in v4.0.30319 directory (or whatever your latest version of .NET compiler is).

csc help

now the main part of the tutorial, the compilation code, here is the compilation code to compile your c# code.


confused ! don't worry, here is snapshot of the complete code using cmd.


here is the complete explanation of the C# code

  • csc : csc stands for C Sharp Compiler.
  • /t:exe : It means the extension of your output, generally "exe" is used.
  • \<Your output destination path>\<Your file name> : Set the destination path and the file name where you want to save the file.
  • \<Your Source Code path> : Set the path where your source code is saved.

and here is the output


There can be various problems that you can arrive into, since C# is a case sensitive language, so did you typed the code exactly same as mentioned in the box, sometimes there can be permissions problem, sometimes there can be a problem in the compiler line.

That's it for now folks ! I hope you enjoyed the article on compiling C# Programmes using Notepad and command line. If any problem arises in the compilation or any sort of error comes during compilation, you can post it as a comment below and TheGeekyWay team will try to solve it ASAP.

You can click the following social icons and share this article with your friends.

© The Geeky Way. Built using Pelican. Theme by Giulio Fidente on github.

Disclaimer Privacy policy