Hello World -- Your First C# Program
To create and run a console application
- Start Visual Studio.
- On the File menu, point to New,
and then click Project.
- In the Templates Categories pane,
expand Visual C#, and then click Windows.
- In the Templates pane, click Console
Application.
- Type a name for your project in the Name field.
- Click OK.
The new project appears
in Solution Explorer.
- If Program.cs is not open in the Code Editor,
right-click Program.cs in Solution Explorer and
then click View Code.
- Replace the contents of Program.cs with the following
code.
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace HelloWorld
{
class Program
{
//The Main method is where you create objects and
execute other methods.
static void Main(string[]
args)
{
Console.WriteLine("Hello World!");
// Keep
the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
9) Press F5 to run the project. A Command
Prompt window appears that contains the line Hello World!

Comments
Post a Comment