Publishing System Settings Logout Login Register
C# - A Basic Understanding
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on March 16th, 2010
3470 views
C#
Hello World

Every time you learn a new programming language you will always start with a Hello World program and C# is no exception.

First of all start up C# and create a new project, name it Hello World and select Console Application.

What you should now see is something similar to this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hello_World
{
class Program
{
static void Main(string[] args)
{
}
}
}

The only thing we will be editing will be within the curly brace after this line:

static void Main(string[] args)

This is the main function of the program and whenever you open the application the contents of this will be run.

To make our program all we need to do is add the following line between the curly braces:

Console.WriteLine("Hello World");
Console.ReadLine();

Now to explain what is happening.

The Console part specifies that what you are going to do will involve the console.

The WriteLine part specifies that you are going Write a Line to the screen.

Now what is inside the parenthesis is what will be output to the screen. We place it within "" to specify that it is not a variable.

Now this part is important, at the end of every statement you must remember to add a semi-colon(;). This tells the compiler that everything after this is a different command.

The next line just pauses the screen until you press a key. If we didn't do this and you ran your code the screen would close instantly and you wouldn't see the results.

So now if we run our code we should see: Hello World! appear on the screen. Well dome you have written your first C# program.

It may look like nothing but I assure you that many of the people who program well know applications like Word and Firefox and World of Warcraft started off writing the same program as you but in another language.

Next up we will be learning about variables and how to assign them and output them.

Next Page
Pages: 1 2 3 4 5
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
chironic

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top