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. One other thing I would like to mention is that as an alternative to trying to match all your online degree tutorials on times that you end work (because most people are fatigued when they come home), try to receive most of your lessons on the week-ends and only one or two courses in weekdays, even if it means a little time off your saturdays. This is fantastic because on the weekends, you will be more rested and concentrated for school work. Thanks alot : ) for the different ideas I have figured out from your blog site.

  2. My brother recommended I would possibly like this web site. He was once entirely right. This publish actually made my day. You cann’t imagine simply how a lot time I had spent for this info! Thanks!

  3. I am so happy to read this. This is the type of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this greatest doc.

  4. Pretty nice post. I just stumbled upon your weblog and wanted to say that I have truly enjoyed surfing around your blog posts. After all I will be subscribing to your feed and I hope you write again very soon!

  5. you’re in point of fact a just right webmaster. The web site loading speed is amazing. It sort of feels that you’re doing any distinctive trick. Moreover, The contents are masterpiece. you have performed a wonderful process in this subject!

Leave a Reply

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