C# Hello World Application  Edit
 Edit
                    
                    
                    In this tutorial we will create our first Hello World application in C# using .NET Framework.
Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hello_World
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World");
            Console.ReadLine();
        }
    }
}
                    Why namespace Hello_World ?
Namespaces are commonly used in C# programming in two ways.
First, .NET uses namespaces to organize its many classes, as follows:
System.Console.WriteLine("Hello World!");System is a namespace and Console is a class in that namespace. The using keyword can be used so that the complete name is not required, as in the below example:using System;Second, declaring your own namespaces can help you control the scope of class and method names in larger programming projects. Use the namespace keyword to declare a namespace, as in the below example:
namespace Hello_World
{
   //write your code here
}
                    Why static void Main(string[] args) ?
C# applications have an entry point called Main Method. It is the first method which gets invoked whenever an application started and it is present in every C# executable file. The most common entry point of a C# program is static void Main() or static void Main(String []args).
static: It means Main Method can be called without an object.
public: It is access modifiers which means the compiler can execute this from anywhere.
void: The Main method doesn't return anything.
Main(): It means program execution starts from here.
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.
 
            
         
                         18 January 2021 |
 18 January 2021 |  5620
5620