This tutorial will guide you how to create your first C# program, build and run it. If you are newbie to C# programming language, this tutorial is very important.
1.2 Let’s go
Creating first C# Program
Creating C# Program requires you to install .net framework. Currently the newest version of .net framework is 4.5. After you have installed .net framework, you must choose an editor to write C# program. The most famous editor is integrated in Microsoft Visual Studio. Others include Sharp Develop, CodeWright, Poorman IDE, EditPlus, JEdit
In this tutorial, I use Microsoft Visual Studio 2010 (.net framework 4.0) to create a C# program. Follow these steps as bellow:
In New Project windows, select type of language is C# and type of program is Console Application, then insert information of the program:
Click OK button to complete creating C# program. Visual Studio will create a solution with a program inside.
Edit the code in Program.cs file as bellow:
- #region "importing libraries area"
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- #region "program"
- namespace MyFirstProgram //this is namespace of our program
- class Program //this is name of our class
- static void Main(string args) //this is function' name. Main function is the starting point of the program
- //You can write you code here
- Console.WriteLine("This is my first C# program!");
Running the program
Click "Run" icon in menu bar or press F5 button to run the program. Bellow is the output of the program above:
In this lesson, we show you some points: