By 22/07/2015 5 Comments

C# Basic Program Structure

Example, a simple program structure:

using System;
namespace csharpBasic
    // Start class definition / declaration.
    class Program
        // Static main method void type declaration.
        static void Main(string[] args)
            // An int type variable is declared and initialized.
            int studentRollNo = 78005;

            // Print variable.

        } // End of main method definition. 
    } // End of class. 

using System; This statement imports system library of framework.
class Program { } Declare a class with name Program.
static void Main(string[] args){ } Declare main method of static and void(return) Type, pass 1 parameter in it (string[] args) which is a single dimensional array with name args. This square brackets { } is a body of that method that contains the main code logic. This is also called a gateway method because when we run the program the compiler calls this method and executes our code.
int studentRollNo = 78005; This statement declares a variable studentRollNo of type int (integer) and assign store 78005 values in it by using assignment (=) operator. This is (;) called sign of termination and is used for terminate any statement (end of- statement), also tells to compiler “This is end of code terminate it”.
Console.WriteLine(studentRollNo); This statement display output as 78005 by passing studentRollNo int (integer) type variable. (Console) keyword is a class name which is exists some where else in dot net’s (System) library (WriteLine(studentRollNo)) is a method of that Console class, pass 1 argument studentRollNo which is 78005 in it. This is a static and void type method of Console class. This method called by Console class using a (.) dot operator, that dot (.) operator Joins that method with its class.

Next Tutorial →

← Previous 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 .