Day 2: C# Hello World Program
2022-08-16T04:09:53 - Vicky Chhetri
Start First Program in C# using visual Studio 2022.
Steps:

Step 2:

Step 3:

Main Program
Filename : program.cs

In .NET 6
program.cs
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
In .NET 5 or earlier
using System;
namespace MyApp // Note: actual namespace depends on the project name.
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
These two forms represent the same program.
Both are valid with C# 10.0. When you use the newer version, you only need to write the body of the Main method.
The compiler synthesizes a Program class with a Main method and places all your top level statements in that Main method.
You don’t need to include the other program elements, the compiler generates them for you.
You can learn more about the code the compiler generates when you use top level statements in the article on top level statements in the C# Guide’s fundamentals section. (Source: docs.microsoft.com)
Older Code Explanation:

Source : tutlane.com
Compile and Run C# Hello World Program

Click green sign and run program.
or
Press F5 to build and compiler the program.
Press ctrl + F5 to run the program.
References
https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates