We will learn about How to create First Console Application. Basic Structure of a C# Program. What is a Namespace. What is the...

Part 1 - Introduction to C#

We will learn about


  • How to create First Console Application.
  • Basic Structure of a C# Program.
  • What is a Namespace.
  • What is the Purpose of Main Method.
To create and run a console application

  • Start Visual Studio.

  • On the menu bar, choose File, New, and Project.

  • The New Project dialog box opens.

  • Expand Installed, expand Templates, expand Visual C#, and then choose Console Application.

  • In the Name box, specify a name for your project, and then choose the OK button.






First Program 

// Namespace Declaration
using System;

class PurushTutorial
{
    public static void Main()
    {
        //Write to Console
        Console.WriteLine("Learning C#");
    }
}


Using System Declaration

The namespace declaration, using System, indicates that we are using the System namespace.

Namespace is used to organize our code and it is collection of classes, interfaces, structs, enums and delegates.

Main Method is the entry point in our Console Application - The execution of our code starts from the first line written in the Main method  

Example - In the above program, execution starts from  "Console.WriteLine("Learning about C#");" ignoring the comment



0 comments: