Thursday, August 16, 2007

Hello World!

Hi everyone!
This blog (as its name shows) is a place dedicated to C# programming.
As a developer\programmer for about 10 years working with Visual Basic 6.0,VB.Net and C# ,I always wish to have a place in web that I can share my experiments with others.
Now I'm working to make that wish come true and here's where I decided to start.

What is C#?

C# is a programming language that let us to write some instructions and compile them to Microsoft.Net IL(intermediate language) that can be executed using Microsoft.Net framework on every machine that has MS.Net framework installed.

How to write C# programs?
To begin writing C# codes, you can download Microsoft.Net framework 2.0 from Microsoft site.
Then you can write you program using a text editor (e.g. NotePad) and compile it using a tool called "csc.exe"(see Hello world section below.)
You can also use Microsoft Visual Studio IDE(integrated development environment)to write and to compile your programs.
There's also an open source IDE for developing C# programs called SharpDevelop.

Hello world!
"Hello world" is a traditional program that provides a quick start for a programming language.You can find "Hello world!" programs written in almost all programming languages here.This program sends a simple Hello world message to an output device (usally the screen).
If you'd like to write a "Hello world!" program in C# you can write the following code in a text editor and save it (From now on,I will write programming codes in italic style.)

public class MyClass
public static void Main()
System.Console.WriteLine("Hello World!");

then you can compile it using csc tool and you will get an exe file.
if you have installed .Net framework 2.0 you can find csc under
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727 folder.
To use csc it is recommended to put it in your windows path so you can run it from any folder on your computer.
You can run csc /? to see its help screen.
To compile your program you can type the following in a dos command window (HelloWorld.txt is the file that you've created in previous step):
csc HelloWorld.txt

This will create a HelloWorld.exe.
If you execute the file you will get a hello world message on your screen.

I will explain the code in next post.