Compiling HelloWorld in C# using CSC

CSC is the C# compiler that comes with .NET and is really simple to use to compile your programs with. Make sure you have the latest .NET version installed before reading on.

Fire up your code editor of choice (even notepad will do) and create your program, e.g. HelloWorld:

using System;

public class HelloWorld
{
        public static void Main()
        {
                Console.WriteLine("Hello World");
        }
}

and save the file out as a .cs file for example HelloWorld.cs

Load up a command prompt (start->run, type 'cmd' without the '' and hit enter). Navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 by typing:

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

where v4.0.30319 is the folder name of the latest version of .NET you have installed.

The compiler executable csc.exe can be found in this folder, and all you have to do next is type

csc c:\path\to\HelloWorld.cs

where c:\path\to\HelloWorld.cs is the location you saved your code to. This will produce HelloWorld.exe in the csc folder which you can test by typing

HelloWorld.exe

assuming you are still in the csc directory under your command prompt.

2011-05-23 19:43:59

New Design

Ok, so after redesigning my main site to be more of a portfolio/random creations repository, it made sense to butcher the blog as well to fit in. Spending a couple of hours stripping WordPress right down to the bare minimum and incorporating the new design was worthwhile, I think.

2011-03-13 12:54:34

Photography Gallery

After recently treating myself to a Nikon D90, I decided to create a php/mysql/jquery/json driven photo gallery to display my photographs - still not 100% complete but its almost there. Click Here to view!

2010-08-01 13:20:45