Domain Empire

"Hello World" Program example with explanation for beginners

Spaceship Spaceship
Watch
"Hello World" Program example with explanation for beginners

Here is your steps to start programming in C#. Let first we create a simple program that will show the basics structure of C# programming.If you find C# syntax more interesting the use it for long term.

"Hello World" Application with C#

Step 1:) Start Visual Studio.net. By clicking Start > Programs > Visual Studio.

Step2 :) Create a new project. By clicking File > New > Project and Select "Visual C# Project" and choose the Console application.A project is created for you with the following coding.

=====Coding Starts ==============
using System;

public class Hello
{
public static void Main (string[] args)
{
Console.WriteLine("Hello World");
}
}
=======Coding End =================================

Step3 :) Compile the application by pressing Ctrl +F5 on the keyboard. Result Will open a new window with text "Hello World"(without quotes).

Step4 :) Let me explain the different lines of the codes so you can understand the basic structure of the application

using System;
---->Here "System" is a namespace and if we want to use any classes of the .Net Framework then first of all we have to write the name of the namespace by using the keyword 'using' that means we are using that namespace classes in our application.Example:"Console.WriteLine" is a part of system Namespace.

public class Hello
----> This is the name of our class.(as I assume you have some knowledge of OOPS concept.)

public static void Main (string[] args)
----> This is the entry point of our program.Here "strin[] args" is the command line parameters.

Console.WriteLine("Hello World");
---> This function will write the "Hello World" on the console.

so above is a small program which will make you familiar with C# syntax and know the basics like how to start a new project, compiling program etc.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back