part-1-c-tutorial-introduction

In this session
1. We will learn the basic structure of a c# program.

// Namespace Declaration

using System;


class Fullstack
{
    //Main method
    public static void Main()
    {
        // Write to console
        Console.WriteLine ("Welcome to Microsoftfullstackdevloper!"); 
    }
}



2. Understand the purpose of using System declaration - The namespace declaration, using System, indicates that you are using the System namespace. If  you omit the using System, declaration, then you have to use the fully qualified name of the Console class. A namespace is used to organize your code and is collection of classes, interfaces, structs, enums and delegates. We will discuss about namespaces in detail in a later session.
3. The class keyword is used for declaring a class.

4. Purpose of Main() method - Main method is the entry point into your application.

5. Purpose of static means Main Method can be called without an object.

6. Purpose of public It is access modifiers which means the compiler can execute this from anywhere.

7. Purpose of void The Main method doesn’t return anything.

8. Purpose of String []args For accepting the zero-indexed command line arguments. args is the user-defined name. So you can change it by a valid identifer. [] must come before the args otherwise compiler will give errors.

9. Without Command line arguments It is up to the user whether he wants to take command line arguments or not. If there is a need for command-line arguments then the user must specify the command line arguments in the Main method.

10. Return Type The Main Method can also have integer return type. Returning an integer value from Main() method cause the program to obtain a status information. The value which is returned from Main() method is treated as the exit code for the process.



// Namespace Declaration

using System;


class Fullstack
{
    // Main Method with int return type
    public int void Main()
    {
        // Write to console
        Console.WriteLine ("Welcome to Microsoftfullstackdevloper!"); 
// for successful execution of code
         return 0;
    }
}

11. Main() method must be static because it is a class level method. To invoked without any instance of the class it must be static. Non-static Main() method will give a compile-time error.

If you can facing any c sharp concept that you are looking for some more, please leave a comment & Email, I will have it added as soon as I can.