C# - Hello Word!
With this tutorial you can make your first 'Hello Word' program in C#
If you have ever learned a programming language, you know that they all start with the "Hello, world!" example, and who are we to break such a fine tradition? Start Visual C# Express (introduced in the last chapter), and select File -> New project… From the project dialog, select the Console application. This is the most basic application type on a Windows system, but don't worry, we won't stay here for long. Once you click Ok, Visual C# Express creates a new project for you, including a file called Program.cs. This is where all the fun is, and it should look something like this:
using System;using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
}
Actually, all these lines doesn't really accomplish anything, or at
least it may seem so. Try running the application by pushing F5 on your
keyboard. This will make Visual C# Express compile and execute your
code, but as you will see, it doesn't do much. You will likely just see
a black window launch and close again. That is because our application
doesn't do anything yet. In the next chapter we will go through these
lines to see what they are all about, but for now, we really would like
to see some results, so let's pretend that we know all about C# and add
a couple of lines to get some output. Within the last set of { }, add
these lines:
Console.WriteLine("Hello, world!");
Console.ReadLine();
The code of your first application should now look like this:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, world!");
Console.ReadLine();
}
}
}
Once again, hit F5 to run it, and you will see the black window
actually staying, and even displaying our greeting to the world. Okay,
so we added two lines of code, but what to they do? One of the nice
things about C# and the .NET framework is the fact that a lot of the
code makes sense even to the untrained eye, which this example shows.
The first line uses the Console class to output a line of text, and the
second one reads a line of text from the console. Read? Why? Actually
this is a bit of a trick, since without it, the application would just
end and close the window with the output before anyone could see it.
The ReadLine command tells the application to wait for input from the
user, and as you will notice, the console window now allows you to
enter text. Press Enter to close it. Congratulations, you have just
created your first C# application! Read on in the next chapter for even
more information about what's actually going on.
-
C# - Hello world explained
| By Victorius | in Programming
I will show you what's the life after Hello Word :)...
-
Hello, people from the real world
| By CHRIS | in General
Hello, people from the real world, hello again hello, ...
-
Classification and uses of words
| By ramilrubio | in Languages
A word is a unit of language that represents a concept which can be expressively communicated with meaning. A word ...
-
hello,here!i am a fresh man in the website,and i would do my best!
| By sinokirin | in General
I am a newer and dont know how to work here...
-
XA Transaction - Solution for Transaction More Than One Database | By H4d1 | in Programming
Have you ever think that it's too difficult for making database transaction in two different places (or databases) ...
-
Javascript functions for : trim, right trim, left trim, no Apostrophe, is Empty , is Digit , VarChar To Number , is integer , check Is Zero , Get Que | By xxris | in Programming
Javascript functions for : trim, right trim, left trim, no Apostrophe, is Empty , is Digit , VarChar To Number , i...
-
How to access and use a Window's command line | By MaxwellPayne | in Programming
Learn about the Window's command line in DOS and how to use it....
-
How to Learn to Program Your Computer | By dsj8760 | in Programming
This article is about learning to program a computer. It is a general article giving tips on how to learn about pro...
-
Jailbroken iPhones get RickRolled | By explorer | in Programming
First iPhone worm, attacks via SSH and does the classic rick roll gag on the user....
-
C# - Looping in statements | By Victorius | in Programming
We must learn how we can loop in statements. Now here we go....
-
C# - The switch statement | By Victorius | in Programming
Another important statement is the switch statement. Now we will learn it :)...
-
C# - The if statement | By Victorius | in Programming
Now we will learn the most important statement....
-
C# - Variables in higher level | By Victorius | in Programming
In this article i will teach you how you can use variables in most of your program....
-
C# - Variable types | By Victorius | in Programming
I will teach you what kind of variables can you use in C#...








great!