‫Welcome back.
‫In this video, we are going to create our first project, the Hello World Application, which is tradition
‫when starting a new programming language.
‫So the idea is to just write a hello world code that will then display in some fashion.
‫In our case, it's going to display it onto the console, which is a little software that will pop up
‫and you will see how that works in a bit.
‫So once you have Visual Studio 2019 opened, you will find this option here to create a new project,
‫which is exactly what we're going to do.
‫So once you click on it, you will find this screen here where you can then select either the recent
‫templates.
‫In my case, it says console application.
‫In your case, it will probably not be available here because you have not created a recent project,
‫but you can select it here from the right hand side.
‫And what is visible for you here depends on the packages that you have installed in your Visual Studio
‫installer.
‫Like we did a couple of videos back.
‫So here you can now select this C-sharp console application.
‫It has to say C-sharp here at the top for this to be the C-sharp version of it, because there's also
‫a visual basic console application and I even believe an F version as well somewhere down there.
‫So what's interesting for us is going to be this one here, which says a project for creating a command
‫line application that can run on the Ethernet core on Windows, Linux and Mac OS.
‫So that's the one that I want to select.
‫By the way, if you had Visual Studio open like this already, as you probably did, then what you can
‫do is you can go to file new and project and from there you can also select this console application.
‫So here the window will pop up in the same manner.
‫So if you select any of the other options here, what will change is going to be the code that will
‫be auto generated for you.
‫So what this basically does is it just generates a bunch of code for us and we don't even have to type
‫it manually ourselves.
‫Of course, you could build an entire software without using an IDE such as Visual Studio and that would
‫be fine as well.
‫But that's a lot more difficult because there are a lot of errors that could appear and you wouldn't
‫even notice them because the it doesn't support you as well as you would have to write all of the code
‫manually yourself and you will see what I mean with this in a second.
‫So let's just select this console application, click next and then give it a name and I'm going to
‫call this one Hello World.
‫It will be stored in this location as you see here, and that will be the solution name.
‫So you could change that if you wanted to.
‫So now let's press next.
‫And here we can select the target framework and I'm going to use dot net 5.0, which is the current
‫version.
‫So in case that it says dot net code 3.1 long term support, that would work as well.
‫It would basically do the same thing, but I would recommend to just use dot net five because that's
‫the latest version of the dot net framework and it's a super powerful framework, which basically means
‫that there is a lot of code already surrounding it and you can just tap into the features that you want
‫to use for your own software, and that's what we're going to do.
‫So we don't want to write everything from scratch.
‫We want to have a framework that really helps us out here, and that's generally a good approach.
‫So now let's go ahead and create this, and this will then automatically generate a program for us.
‫So there we are by default.
‫It generated this program CSS file for me and the project itself.
‫So if we look at the project, you can right click here and you can go over to your open folder and
‫file explorer and that will then show you all of the files that have been generated.
‫So it generated this Helloworld folder with this SLN, which is the Visual Studio Solution file, which
‫basically would open up this project that we have there.
‫And then if you go deeper, you will find the bin folder with the debug folder as well as the object
‫folder, also with the debug and a couple of files.
‫And then what's interesting is this program CSS.
‫So if you double click on it, it will automatically open up in Visual Studio as you see here.
‫But you can also open it by right clicking and editing here, for example, and then it will open up
‫in the editor.
‫So here you see that this is where you could also write your code directly in the editor.
‫But the beauty really is in Visual Studio code that you have this color coding which helps you out as
‫well as it understands if we have an error in our code.
‫So for example, if I forget the semicolon here at the end it will display, hey, there is something
‫missing.
‫And it even says semicolon was expected.
‫So let me add that back there.
‫All right.
‫So now what's going on on the screen?
‫What we have this using system, what that does is it basically says, I want to use the namespace called
‫system.
‫And this namespace system has a bunch of different classes which you can then use.
‫So basically functionality that you can then use.
‫And this using system has, for example, details about what a console is.
‫So once you hover over this console keyword, you will see that it says class system, dot console.
‫So there is this namespace called system which contains a bunch of classes and we can use those now
‫in our project because we just added the namespace and we can later on add namespaces for example,
‫if you want to send emails and we can just add an email namespace here and then that will give us a
‫bunch of classes that we can use in order to, for example, send emails with our software.
‫Now we're creating our own namespace called Helloworld, and instead of this namespace called Helloworld,
‫we have our own class that we called program, and that was done for us by default because we didn't
‫change this name ourselves.
‫But that's fine.
‫So you can see it says Class Hello World Program.
‫Similar to what we have here, once we hover over console where it says class system that console.
‫So every single class has a certain functionality and in our case, this class program here has just
‫one functionality where it goes into this main method.
‫So this is the entry point of any program.
‫And then here, I'm just going to add a comment here, entry point of our program.
‫So this here is a comment.
‫I'm using double slashes here in order to make sure that I am writing a comment that will not impact
‫our software whatsoever.
‫So our program will do exactly as it did without this line of code.
‫But what this line of code does for us is it helps us to understand what's happening in the code so
‫we as programmers can just add this, and somebody else who reads our code later on can understand what
‫we wrote there.
‫Because the more complex your software gets, the more difficult it is to understand and the more important
‫it is that you have these kind of comments that help you understand what every single line does.
‫So that's what I would recommend that you do if you really want to learn quicker, is that you add a
‫comment after every single line that you are writing.
‫If you don't fully understand it, you try to write a comment about trying to understand what's written
‫there by maybe rewatching a certain part of the video and so forth.
‫So this is the entry point of our program.
‫We're not going to look into too much what's the static means?
‫And for now just means that we don't need to create an object in order to run this method.
‫What that means, it would be way too much for at this point of the course.
‫We're going to see what that means later on in the course.
‫Then we say that this method is void so it doesn't return anything.
‫We're going to see what that means once we're looking into methods and then this is the actual method,
‫we're going to see what methods are later on as well.
‫So basically we're saying, okay, this is the entry point of our program and once we run our program,
‫please run whatever code is inside of these curly brackets here.
‫And for now, what it does is it uses this console which is predefined code, which is inside of this
‫system namespace and it uses its own method called right line, which then writes onto the console.
‫So once you hover over this console here, it says represents the standard input output in error streams
‫for console applications.
‫So now if you run our program, we will see that it automatically opens up this little window and it
‫says Hello world here.
‫So this is what our software now does for us.
‫And where does it come from?
‫Well, it came from hello world bin debug dot net 5.0.
‫Hello World X.
‫Okay, so that file was executed for us and it said hello world.
‫So now instead of saying hello world, let's add another line.
‫So let's just copy this line here, let's add it underneath and say something like, Hello, Dennis.
‫In my case it's going to say Hello, Dennis.
‫And in your case, what I would like you to do is I would like you to change that, to say hello and
‫then your name.
‫Okay.
‫And then now it will say hello world in one line.
‫And in the second line it will say Hello, Dennis.
‫So let's run the software real quick and you see it says Hello World and one line.
‫And in the second line it says, Hello, Dennis.
‫Now what you can also see is that instead of this right line, you have these brackets.
‫Inside of those brackets, you have this string.
‫That's the official name of it, basically a piece of text where you need to surround it with quotation
‫marks, as you see here.
‫And then we have a closing bracket as well as a semicolon at the end.
‫And semicolon is very important in programming, at least in most programming languages.
‫There are some programming languages that are not using a semicolon at the end of each line, but in
‫C sharp it's required.
‫So we're basically saying, okay, this is where the statement ends.
‫So here we are finishing it with a semicolon.
‫So the same goes here.
‫We're finishing the statement and we're adding a semicolon.
‫This might look a little weird at the beginning, but no worries.
‫You're going to get a hang of it later on.
‫So now what you can also see is that there are a bunch of curly brackets.
‫So here this namespace hello world has a curly bracket and opening one here and the closing one down
‫there, which is automatically also marked once I mark one of them.
‫So it says, okay, this part is now my body.
‫So this is the part that is inside of me.
‫So here the class, all of this code here is inside of the Helloworld namespace and then this stuff
‫here is inside of the class program.
‫And then we have this method called Main and inside of it is that code here.
‫So at the left hand side you can even see these minuses here and you can collapse the entries, the
‫code by just pressing on them.
‫And this will then.
‫Shrink your code, but the code is still there.
‫Now, another very short, very interesting thing that I wanted to show you is that if you open the
‫folder in the file Explorer and you actually go to bin debug dot net five, you will find that there
‫is this helloworld exe file.
‫So if you click on that, it will also open the console.
‫But unfortunately it's closing straightaway.
‫So if you want to make sure that it stays open, then you need to add this line here which says console
‫dot read.
‫So what that will do is it will read the next character from the standard input stream.
‫And we also need to use these brackets because we're actually calling a method.
‫As I said, we're going to see what methods are later on and we need a semicolon in order to finish
‫this statement.
‫So now if you run this code, it will run as it did before, but it's going to stay open and let me
‫press a key, and then it will close, so to speak, even though in Visual Studio, by default, it
‫leaves this window open for us for debugging.
‫You can turn this off if you go to this setting here.
‫So tools, options, debugging automatically close to console with debugging stops.
‫So feel free to make that change.
‫But what's interesting now is if you go back to our hello world exa that's the window is now staying
‫open so it stays open.
‫And now once we press the key, it closes.
‫Okay.
‫So this is our software.
‫So now we wrote our own Excel file, and we can use this Excel file in order to impress our friends.
‫All right.
‫So that's it for this video.
‫See you in the next one.