Friday, 21 March 2014

1: Hello World C# Program

C# Hello World Program
C sharp is an object oriented language derived from C and C++, Introduce by Microsoft.
Let’s start our first program that is hello world
  1. Open visual studio
  2. New project

New window will appear
  1.     On left side select windows
  2.     At the middle select template console application
  3.     Then give it name “helloword”

IDE(integrated development environment) will open following window for you



Let’s try some code
As you know in c language we use printf() for printing something on the screen and getche() functions for holding screen.
Similarly we are going to do similar thing in C#.

Let’s look on console.WriteLine(“Hello World”); which is similar to Printf(“Hello Wolrd\n”);
In object oriented programming almost work done by classes and object so here
Console is a class which have method name WriteLine() which take parameter like printf() to print on the console  window.
Now Let’s look on console.ReadLine(); which is similar to getche();
Readline() is also a method of console class which hold screen until you press enter key.

Console class located in the system namespace as you can see at the top of the code.
Using System;

These work similar as we define libraries in c language include.stdio etc, if you remove using System; then you won’t be able to use console class.

No comments:

Post a Comment