By 22/07/2015 11 Comments

First C# Project

  • Make sure that you have installed visual studio 2013.
  • Open visual studio 2013 by double click on it, create a new project (File -> New -> Project) [Fig: 1.1], then go to (installed -> Templates -> Visual C#) now in center window select [Console Application] option then enter a name and location for your project and click Ok to generate a C# project [Fig: 1.2]. Your first C# project has been generated now.

New-project

Fig: [1.1] Creating a new project

 Creating and generating a C# project

Fig: [1.2] Creating and generating a C# project

Remember:

  • C# cannot be generated as an individual project only, but any of the ASP.NET project types support C#.
  • You can include the C# files in any type of project by simply adding them with .cs file extension within that project and visual studio will automatically start compiling C# files as a part of new project.

Default project files:

  • Once a new C# project has been created, the project template generates the following files automatically [Fig: 1.3].
  1. Program.cs
  2. App.config
Default C# generated project files

Fig: [1.3] Default C# generated project files

  • If we will run this project (press F5 or Start button) [Fig: 1.4], now we can see the output of this project because this is a complete and running default C# application [Fig: 1.5].

Run C# project

Fig: [1.4] Run C# project

C# project is running in console window (output)

Fig: [1.5] C# project is running in console window (output)



A closer look at C# file: Program.cs:

/* .NET Framework's different libraries are imported.
 * In this program we need only one library: using System; */

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

// A namespace declaration. Visual studio generates that namespaces automatically.
namespace HelloWord
{
    // Class declaration which is automatically generated by visual studio.
    class Program
    {
        /* A static method, automatically generated through visual studio.
         * This is a gateway main method, when we run C# program the C#'s Common Language Runtime-
           CLR makes a call to this method and code inside this method will be executed (output). */
        
        static void Main(string[] args)
        {
            // A print statement which displays a message.
            Console.WriteLine("Hello word! My first C# program...");
            Console.ReadKey();
        }
    }
}

A closer look at App.config file:



 


     
      
        
    






Next Tutorial →



Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .