Monday 29 August 2016

Part1 C# Introduction

How to create a project?
Open Visual studio => File => New => Project


Select visual C# in Installed Template
Select Console application
Give your project name in Name TextBox
Browse Location  for where it store this project


Sample Program

using System;   //Namespace declaration

class Program
{
    static void Main()  //Main method, The entry point of the project
    {
        //Write in console
        Console.WriteLine("Welcome to my C# blog");
        Console.ReadLine();
    }
}
Output: Welcome to my C# blog


What is Namespace?
     Namespace is collection of classes, interfaces, enums, structs and delegates.
     Namespace is used to organize your code.
For Example,
using System is tells that use of code present inside.

Note:
If we not using System then just type System.Console, but more times we are using System so we declare namespace at top


What is Main method?
     Main method is a entry point into your application

Sample Program

using System;

class Program
{
    static void MainTwo()
    {
        Console.WriteLine("Welcome to my .net blog");
    }

    static void Main()
    {
        Console.WriteLine("Welcome to my C# blog");
        MainTwo();
        Console.ReadLine();
    }
}

Output: 
Welcome to my C# blog
Welcome to my .net blog



No comments:

Post a Comment