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
- Open visual studio
- New project
- On left side select windows
- At the middle select template console application
- Then give it name “helloword”
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