C# Structure: Namespaces, Classes, Methods, Statements

Structure of C#

Basic Structure of C# Program is Namespaces => Class => Members => Methods/Blocks => Statements

Namespace in C#

Namespaces are common to share the same name with a folder and the role is to declare a scope that contains a set of related objects

Class in C#

Class is a data structure that has data variables and functions in a single unit object. Class is just a blueprint to make instances, Instance is the object that the class is initiated

Members in C#

Members are the part of blueprint, They can be file properties, methods events, and constructors.

Methods in C#

Methods/blocks are a block of code that contains a series of statements and execute the statements when the Method is called

Statements in C#

Statements are small units of code that express actions, they can be calling methods, declaring variables.

//Importing system
using System;
//Namespzce
namespace BasicCsharp
{
    //class
    class className
    {
        //member
        int member1 = 1;
        int member2 = 2;    
        //method
        static void codeBlock()
        {
            //statement
            Console.WriteLine("Statement inside codeblock");
        }
        public static void Main(string[] args) 
        {
            codeBlock();
        }
    }
}

Output

Output

This is the basic structure of C#