|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionYou may think that the title of this article looks something odd and too lengthy. So, before moving on to the point, let me first explain to you the title. By "Traditional Hello World", I mean that when we try to learn a new language, as the tradition goes on, we always introduce the language with a "Hello World" program. This is just a simple program which displays "Hello World" on the console screen. (PART-I) By "Using Different Approaches", I mean that I would explain the "Hello World" program using various methods. So, the reader gets a basic and clear understanding of Object Oriented Programming using C#. (PART-II) So folks, without breaking the tradition, let's move on to our program: /*1*/ using System;
/*2*/ public class world
/*3*/ {
/*4*/ public static void Main()
/*5*/ {
/*6*/ Console.WriteLine("Hello World");
/*7*/ }
/*8*/ }
You can type this code into Notepad or any of your favorite editor and save the file as helloworld.cs (you can save it with any name but the extension should be .cs). After saving the file, go to console screen (i.e., the black colored DOS prompt Window) and type csc helloworld.cs and press Enter. The program would successfully compile, provided that there is .NET platform installed on your PC and the program is typed correctly without any mistakes. This would generate a file as helloworld.exe which when run will give you "Hello World" on the screen. Let us now examine the different parts of our Helloworld program: LINE: 1using System;
LINE: 2public class world
LINE: 3{
Starting curly braces for class LINE: 4public static void Main()
This is the main entry point of this program.
LINE: 5{
Starting curly brace for method LINE: 6Console.WriteLine("Hello World")
At last, I am on the actual line of the code which displays the traditional holy word (FOR PYSCHOs) "Hello World".
And "HelloWorld" is the string that we pass in the LINE: 7}
Closing curly brace for method LINE: 8}
Closing curly brace for class So folks, if you want to thank me, then what would you do? Let me guess. You would change line 6 as: Console.WriteLine("Thank You Nemesh");
I have also uploaded the second part of this article Traditional Hello World Program using different approaches. PART -II.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||