Changes

Jump to: navigation, search

A Simple C Sharp Console Application

9 bytes removed, 14:24, 1 April 2009
no edit summary
In the early 1970's 1970s the creators of the C Programming Language wrote a book of the same name intended to teach the skills necessary to program in C. One of the first chapters of this book contained a very simple C program which simply displayed the words "Hello World" in a console. Ever since that day most programming books has have followed this tradition. Given that C# can trace its ancestry to the C programming language , [[C Sharp Essentials|C# Essentials]] will be no exception to this rule.
Even if you are an experienced programmer this simple C# example is still recommended if only to verify that the C# development environment is correctly installed.
There are a number of options for installing an environment suitable for compiling and executing a C# program. If you are running on Windows you can either install Visual Studio (either the professional edition or the free express edition). If you prefer a lighter weight solution you can simply download and install latest .NET Framework which includes the C# compiler and the runtime environment. This can be downloaded from [http://msdn2.microsoft.com/en-us/netframework/aa569263.aspx the Microsoft website].
Once installed , the compiler will need to be run from a command prompt window. The compiler executable is called ''CSC.EXE'' and by default it is not in the command path. Find where CSC.EXE is installed on your system (in .NET Framework 3.5 on Windows XP it is installed in the \WINDOWS\Microsoft.NET\Framework\v3.5) by performing a Search of your disk drives. Once the location has been ascertained, add the location to the path environment variable:
<pre>
</pre>
Those familiar with C++ or Java will feel extremely comfortable with the above code and will clearly see the C#'s lineage from these languages. Having saved the C# source code the next task is to compile it.
== Compiling C# Code From from the Command Line ==
Having written the C# source code the next step is to compile it down to the Common Intermediate Language (CLI) format. If you have installed the .NET Framework and configured your PATH so that the C# compiler can be found then you are ready to compile. If, on the other hand, you installed Visual Studio you can launch a Command Tool ready compile by selecting ''Start->All Programs->Microsoft Visual Studio->Visual Studio Tools->Visual Studio Command Prompt''.

Navigation menu