Your first C# Project in Visual Studio – Hello World
In Programming it is common to develop the Hello World program as a very first project in a new language. Just to test if everything is setup correctly. In this video we will do just that. When starting Visual Studio for the first time, a Startpage opens up. In this one you can click on “New Project…” to start a new project. Do that and follow the instructions. You can choose an own name for the project. Choose Installed -> Visual C# -> Console Application. As we will work with console applications for this course. As soon as you are done creating the project, you program will have to following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Projectname
{
class Program
{
static void Main(string[] args)
{
}
}
}
Hereby using means that the program should use certain libraries. Libraries contain loads of more Code which we can now use. This allows us to use functionality in our application, which we haven’t written our self. Pretty cool, huh? 😉
How exactly that works and what does functionalities are will be covered later down the road.
The namespace is our project. It contains our first class (all the stuff between the {}). The main function is the starting point of our application. Each program needs to have that, else it wont start. What this static void and string and all that stuff means will be covered in later videos.
Important for now is the following: you can now add code to in between the curly brackets in the center, in order to add functionality to your code.
For example:
Console.WriteLine("Hello World");
Console.Read();
Add this code into your Main function and start the application with CTRL + F5.
Your application should say: Hello World.
Congratulations, you have written your very first application in CSharp! 🙂
This is not enough of course. In the following videos you will learn everything you need to know in order to make much more complex applications.
I wish you loads of fun!