Introduction to Programming in C# – The Hands-on Approach

Before we get started in programming C#, head over to Microsoft to download visual studio. Here is the link, if you would rather search for it, type in “visual studio” in Google.

Here select the Community 2022 option. This will give you all the features you’ll need while learning.

This part of the install window gives a lot of options. Under the Desktop and Mobile section select .NET desktop development. That will give you the ability to make console applications and follow along with the exercises here. Go ahead and select anything else you are interested in.

After everything downloads, it’s time to start a project. This is the window you’ll see every time you open Visual Studio.

The window shows a few different options. From top to bottom you have clone a repository from GitHub (article coming soon), open a project, open a folder, and create a new project.

Select create a new project to go to the next step.

Here is the list of all the project templates. The length of the list will be dependent on what you chose during installation.

For this first program select, “Console App.”

If you don’t see that option readily available type ‘console’ in the search bar above the list.

Once you have Console App select, press Next to move on.

For this step you can select the project name. If you want to follow along with the posts on here, name the solution Foundations and name the project 01FirstProgram.

As we continue you’ll see that we can put multiple projects within the same solution.

The last step before getting to write and run a program involves selecting the framework. Currently .NET 6 and .NET 7 are available. 

For now, select .NET 6 and click on Create.

If you followed everything I’ve covered so far, here is what you should see:

There is a lot to unpack here but for this post I’ll keep it simple.

Line 2 in the Program.cs window is our program. The line Console.WriteLine(“Hello, world!”); is common first program for new developers. With Visual Studio it’s already written in for you. If you would like to see the program run, click the green play button near the top middle that says 01FirstProgram and see what happens.

If you see something like this, likely with different colors, good job. You successfully ran your first C# program!

Before moving on I’ll go over what the program. Console.WriteLine is a built in function that displays output into the console window like you can see in the image above. Think of it like the program telling the computer, “hey computer, bring up the console, and write this on the display window.” The function can display text like we saw here, a number, or both.

Try experimenting by putting your name in the quotation marks, adding another Console.WriteLine(); line with something else in it. Try a number. In the next post I’ll cover variables.

To see this code on GitHub click here.

Leave a Comment

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