Rebirth of T-rex

Does dinosaur really extinct? What caused the dinosaur to vanish? Have you ever wonder whether the real 'you' is disappearing and slowly vanishing? Hope that through this blog, we will be able to maintain the real self.

My First C# Hello World

Posted by T-rex Lim Huat Heng

I woke up early in the morning and suddenly wanted to write my first C# Hello World program after Sunday's conversation with my best friend- Boo. He told me that I can just write a simple C# program then compile and run without MS. Visual Studio .Net, but as long as I have the .Net Framework 1.1 installed.Thus, I started to study some sample Hello World over the Internet and so eager to get it run. Opps I got stuck because I don't know how to call the C# compiler. Luckily I met my MMU junior (Teck Kong) who is .Net expert. So, I summarized the basic steps in the following for others to refer.

First need to install the .Net Framework 1.1, in which you can get from http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=en.

Assume the installation for .Net Framework is successful, then you need to add the path into the environment variable 'PATH'.
If you are using Windows XP, you can easily do this by right click on My Computer icon and select Properties from the pop-up menu, then select Advance tab and click Environment Variables button. Locate the variable 'PATH' (by left click on the entry) from the System Variables list and click Edit button.Input ';C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322' (the semicolon is used as delimiter to seperate different values) at the end of content of Variable Value.Then apply the changes.

You can start writing the first code by typing the following in a notepad or any other text editor then save as HelloWorld.cs.

using System;
public class HelloWorld {

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

Once completed, start a command prompt and navigate to where the C# code is, eg. C:\CSharpTutorial, and type csc HelloWorld.cs to compile it. You will see the following as the output, assuming there is no compilation error:

Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

If you observe the folder, there will be a new file created with the name HelloWorld.exe. So we can just execute the file like normal Windows EXE. Just type the following in the command prompt:

HelloWorld

and you should get the following as the output.

Hello World!

Enjoy!

6 comments:

Anonymous said...

great Ko Ko try c#. i used it in my finaly yaer project : )

T-rex Lim Huat Heng said...

Mei Mei, I will bother you once I have problem later. So, I teach you Java and you teach me C#- students exchange programme :P

Anonymous said...

lolz...sure no problem if i can giv u a hand. my pleasure :)

fr mei mei

Anonymous said...

';C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322'
well, this command will works in Windows XP for sure, but not for Windows 2000.. too bad i'm using Win2000 now.. erm.. just change the command to ';C:\WINNT\Microsoft.NET\Framework\v1.1.4322', then it will work also.. but i dun think got anyone using Win2000 now huh?? --LY

Anonymous said...

...please where can I buy a unicorn?

Anonymous said...

la informaciГіn de valor http://nuevascarreras.com/comprar-cialis-es/ cialis genericos Mi scuso, ma non abbastanza in forma. cialis 5 mg posologia esvyjppgja [url=http://www.mister-wong.es/user/COMPRARCIALIS/comprar-viagra/]comprar viagra[/url]