Understanding the building blocks of a C# application
Every C# program follows a specific structure that the compiler recognizes. The most basic C# program consists of a class with a Main method.
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
        }
    }
}The using System; directive allows you to use types from the System namespace without specifying the full namespace each time.
Namespaces help organize code and prevent naming collisions. The namespace HelloWorld declaration defines a container for related types.
Classes are the fundamental building blocks of C# programs. class Program defines a class named Program.
The Main method is the entry point of a C# application. It must be static, and it's where the program starts execution.
The code between the curly braces {} is the method body containing statements that execute when the program runs.
Every C# application must have exactly one Main method as its entry point. The compiler will generate an error if no Main method is found, or if multiple Main methods exist without specifying which to use.
C# is case-sensitive. "Main" is different from "main". The entry point method must be named "Main" with a capital M.
// Using directives to import namespaces
using System;
using System.Collections.Generic;
// Namespace declaration
namespace CompanyApp
{
    // Class declaration
    class Program
    {
        // Main method - entry point
        static void Main(string[] args)
        {
            // Program execution starts here
            Console.WriteLine("Application started!");
            
            // Check command line arguments
            if (args.Length > 0)
            {
                Console.WriteLine($"Received {args.Length} arguments");
            }
            
            // Call another method
            DisplayMessage();
            
            // Keep console window open
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
        
        // Custom method
        static void DisplayMessage()
        {
            Console.WriteLine("Hello from DisplayMessage method!");
        }
    }
}Understanding how a C# program executes from start to finish
