0 0
Read Time:1 Minute, 5 Second

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

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

About Author

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
100%
1 Star
0%

168 thoughts on “Day 2: C# Hello World Program

  1. Thanks alot : ) for your post. I’d like to comment that the cost of car insurance varies from one scheme to another, simply because there are so many different issues which contribute to the overall cost. For instance, the brand name of the auto will have a massive bearing on the price tag. A reliable aged family automobile will have a lower priced premium compared to a flashy fancy car.

  2. I would like to thank you for the efforts you have put in writing this site. I am hoping the same high-grade web site post from you in the upcoming also. In fact your creative writing abilities has inspired me to get my own web site now. Really the blogging is spreading its wings quickly. Your write up is a great example of it.

  3. What an informative and thoroughly-researched article! The author’s attention to detail and ability to present complicated ideas in a understandable manner is truly praiseworthy. I’m extremely captivated by the depth of knowledge showcased in this piece. Thank you, author, for sharing your wisdom with us. This article has been a game-changer!

  4. I?ve learn a few good stuff here. Definitely worth bookmarking for revisiting. I wonder how much attempt you place to make this sort of excellent informative website.

Leave a Reply

Your email address will not be published. Required fields are marked *