1 00:00:01,270 --> 00:00:02,110 ‫Welcome back. 2 00:00:02,140 --> 00:00:08,740 ‫In this video, we are going to create our first project, the Hello World Application, which is tradition 3 00:00:08,740 --> 00:00:10,890 ‫when starting a new programming language. 4 00:00:10,900 --> 00:00:16,990 ‫So the idea is to just write a hello world code that will then display in some fashion. 5 00:00:16,990 --> 00:00:22,540 ‫In our case, it's going to display it onto the console, which is a little software that will pop up 6 00:00:22,540 --> 00:00:24,700 ‫and you will see how that works in a bit. 7 00:00:24,790 --> 00:00:32,170 ‫So once you have Visual Studio 2019 opened, you will find this option here to create a new project, 8 00:00:32,170 --> 00:00:34,120 ‫which is exactly what we're going to do. 9 00:00:34,120 --> 00:00:39,880 ‫So once you click on it, you will find this screen here where you can then select either the recent 10 00:00:39,880 --> 00:00:40,330 ‫templates. 11 00:00:40,330 --> 00:00:42,640 ‫In my case, it says console application. 12 00:00:42,640 --> 00:00:47,620 ‫In your case, it will probably not be available here because you have not created a recent project, 13 00:00:47,620 --> 00:00:50,530 ‫but you can select it here from the right hand side. 14 00:00:50,530 --> 00:00:57,400 ‫And what is visible for you here depends on the packages that you have installed in your Visual Studio 15 00:00:57,400 --> 00:00:57,910 ‫installer. 16 00:00:57,910 --> 00:01:00,430 ‫Like we did a couple of videos back. 17 00:01:00,610 --> 00:01:05,530 ‫So here you can now select this C-sharp console application. 18 00:01:05,540 --> 00:01:10,750 ‫It has to say C-sharp here at the top for this to be the C-sharp version of it, because there's also 19 00:01:10,750 --> 00:01:16,750 ‫a visual basic console application and I even believe an F version as well somewhere down there. 20 00:01:16,750 --> 00:01:21,310 ‫So what's interesting for us is going to be this one here, which says a project for creating a command 21 00:01:21,310 --> 00:01:26,050 ‫line application that can run on the Ethernet core on Windows, Linux and Mac OS. 22 00:01:26,140 --> 00:01:28,960 ‫So that's the one that I want to select. 23 00:01:29,050 --> 00:01:35,020 ‫By the way, if you had Visual Studio open like this already, as you probably did, then what you can 24 00:01:35,020 --> 00:01:41,710 ‫do is you can go to file new and project and from there you can also select this console application. 25 00:01:41,710 --> 00:01:44,440 ‫So here the window will pop up in the same manner. 26 00:01:44,590 --> 00:01:52,030 ‫So if you select any of the other options here, what will change is going to be the code that will 27 00:01:52,030 --> 00:01:53,830 ‫be auto generated for you. 28 00:01:53,830 --> 00:01:59,800 ‫So what this basically does is it just generates a bunch of code for us and we don't even have to type 29 00:01:59,800 --> 00:02:01,600 ‫it manually ourselves. 30 00:02:01,600 --> 00:02:09,010 ‫Of course, you could build an entire software without using an IDE such as Visual Studio and that would 31 00:02:09,010 --> 00:02:09,730 ‫be fine as well. 32 00:02:09,730 --> 00:02:14,860 ‫But that's a lot more difficult because there are a lot of errors that could appear and you wouldn't 33 00:02:14,860 --> 00:02:20,170 ‫even notice them because the it doesn't support you as well as you would have to write all of the code 34 00:02:20,170 --> 00:02:23,620 ‫manually yourself and you will see what I mean with this in a second. 35 00:02:23,620 --> 00:02:29,680 ‫So let's just select this console application, click next and then give it a name and I'm going to 36 00:02:29,680 --> 00:02:31,150 ‫call this one Hello World. 37 00:02:31,780 --> 00:02:37,140 ‫It will be stored in this location as you see here, and that will be the solution name. 38 00:02:37,150 --> 00:02:39,220 ‫So you could change that if you wanted to. 39 00:02:39,220 --> 00:02:41,260 ‫So now let's press next. 40 00:02:41,260 --> 00:02:47,200 ‫And here we can select the target framework and I'm going to use dot net 5.0, which is the current 41 00:02:47,200 --> 00:02:47,860 ‫version. 42 00:02:47,860 --> 00:02:53,920 ‫So in case that it says dot net code 3.1 long term support, that would work as well. 43 00:02:53,920 --> 00:02:58,720 ‫It would basically do the same thing, but I would recommend to just use dot net five because that's 44 00:02:58,720 --> 00:03:05,770 ‫the latest version of the dot net framework and it's a super powerful framework, which basically means 45 00:03:05,770 --> 00:03:10,390 ‫that there is a lot of code already surrounding it and you can just tap into the features that you want 46 00:03:10,390 --> 00:03:14,290 ‫to use for your own software, and that's what we're going to do. 47 00:03:14,290 --> 00:03:17,290 ‫So we don't want to write everything from scratch. 48 00:03:17,290 --> 00:03:22,900 ‫We want to have a framework that really helps us out here, and that's generally a good approach. 49 00:03:22,900 --> 00:03:30,340 ‫So now let's go ahead and create this, and this will then automatically generate a program for us. 50 00:03:31,840 --> 00:03:33,760 ‫So there we are by default. 51 00:03:33,760 --> 00:03:40,130 ‫It generated this program CSS file for me and the project itself. 52 00:03:40,150 --> 00:03:46,420 ‫So if we look at the project, you can right click here and you can go over to your open folder and 53 00:03:46,420 --> 00:03:51,600 ‫file explorer and that will then show you all of the files that have been generated. 54 00:03:51,610 --> 00:04:00,490 ‫So it generated this Helloworld folder with this SLN, which is the Visual Studio Solution file, which 55 00:04:00,490 --> 00:04:03,450 ‫basically would open up this project that we have there. 56 00:04:03,460 --> 00:04:10,030 ‫And then if you go deeper, you will find the bin folder with the debug folder as well as the object 57 00:04:10,030 --> 00:04:13,010 ‫folder, also with the debug and a couple of files. 58 00:04:13,030 --> 00:04:16,180 ‫And then what's interesting is this program CSS. 59 00:04:16,180 --> 00:04:22,150 ‫So if you double click on it, it will automatically open up in Visual Studio as you see here. 60 00:04:22,150 --> 00:04:28,480 ‫But you can also open it by right clicking and editing here, for example, and then it will open up 61 00:04:28,480 --> 00:04:29,350 ‫in the editor. 62 00:04:29,350 --> 00:04:34,540 ‫So here you see that this is where you could also write your code directly in the editor. 63 00:04:35,140 --> 00:04:42,130 ‫But the beauty really is in Visual Studio code that you have this color coding which helps you out as 64 00:04:42,130 --> 00:04:46,320 ‫well as it understands if we have an error in our code. 65 00:04:46,330 --> 00:04:51,940 ‫So for example, if I forget the semicolon here at the end it will display, hey, there is something 66 00:04:51,940 --> 00:04:52,630 ‫missing. 67 00:04:52,630 --> 00:04:56,140 ‫And it even says semicolon was expected. 68 00:04:56,140 --> 00:04:58,150 ‫So let me add that back there. 69 00:04:58,300 --> 00:04:58,690 ‫All right. 70 00:04:58,690 --> 00:05:00,730 ‫So now what's going on on the screen? 71 00:05:00,970 --> 00:05:09,310 ‫What we have this using system, what that does is it basically says, I want to use the namespace called 72 00:05:09,310 --> 00:05:09,970 ‫system. 73 00:05:09,970 --> 00:05:15,790 ‫And this namespace system has a bunch of different classes which you can then use. 74 00:05:15,790 --> 00:05:18,400 ‫So basically functionality that you can then use. 75 00:05:18,400 --> 00:05:23,590 ‫And this using system has, for example, details about what a console is. 76 00:05:23,590 --> 00:05:30,010 ‫So once you hover over this console keyword, you will see that it says class system, dot console. 77 00:05:30,010 --> 00:05:38,590 ‫So there is this namespace called system which contains a bunch of classes and we can use those now 78 00:05:38,590 --> 00:05:45,220 ‫in our project because we just added the namespace and we can later on add namespaces for example, 79 00:05:45,220 --> 00:05:51,370 ‫if you want to send emails and we can just add an email namespace here and then that will give us a 80 00:05:51,370 --> 00:05:56,410 ‫bunch of classes that we can use in order to, for example, send emails with our software. 81 00:05:56,830 --> 00:06:03,640 ‫Now we're creating our own namespace called Helloworld, and instead of this namespace called Helloworld, 82 00:06:03,760 --> 00:06:10,330 ‫we have our own class that we called program, and that was done for us by default because we didn't 83 00:06:10,330 --> 00:06:12,190 ‫change this name ourselves. 84 00:06:12,190 --> 00:06:13,330 ‫But that's fine. 85 00:06:13,330 --> 00:06:16,480 ‫So you can see it says Class Hello World Program. 86 00:06:16,480 --> 00:06:22,030 ‫Similar to what we have here, once we hover over console where it says class system that console. 87 00:06:22,900 --> 00:06:29,230 ‫So every single class has a certain functionality and in our case, this class program here has just 88 00:06:29,230 --> 00:06:34,120 ‫one functionality where it goes into this main method. 89 00:06:34,120 --> 00:06:37,330 ‫So this is the entry point of any program. 90 00:06:38,130 --> 00:06:45,360 ‫And then here, I'm just going to add a comment here, entry point of our program. 91 00:06:45,960 --> 00:06:48,210 ‫So this here is a comment. 92 00:06:49,380 --> 00:06:57,570 ‫I'm using double slashes here in order to make sure that I am writing a comment that will not impact 93 00:06:57,570 --> 00:06:59,880 ‫our software whatsoever. 94 00:06:59,880 --> 00:07:03,990 ‫So our program will do exactly as it did without this line of code. 95 00:07:03,990 --> 00:07:10,680 ‫But what this line of code does for us is it helps us to understand what's happening in the code so 96 00:07:10,680 --> 00:07:16,680 ‫we as programmers can just add this, and somebody else who reads our code later on can understand what 97 00:07:16,680 --> 00:07:17,550 ‫we wrote there. 98 00:07:17,550 --> 00:07:23,580 ‫Because the more complex your software gets, the more difficult it is to understand and the more important 99 00:07:23,580 --> 00:07:28,260 ‫it is that you have these kind of comments that help you understand what every single line does. 100 00:07:28,260 --> 00:07:35,070 ‫So that's what I would recommend that you do if you really want to learn quicker, is that you add a 101 00:07:35,070 --> 00:07:38,910 ‫comment after every single line that you are writing. 102 00:07:38,910 --> 00:07:44,400 ‫If you don't fully understand it, you try to write a comment about trying to understand what's written 103 00:07:44,400 --> 00:07:48,540 ‫there by maybe rewatching a certain part of the video and so forth. 104 00:07:49,080 --> 00:07:51,600 ‫So this is the entry point of our program. 105 00:07:51,600 --> 00:07:54,630 ‫We're not going to look into too much what's the static means? 106 00:07:54,630 --> 00:07:59,760 ‫And for now just means that we don't need to create an object in order to run this method. 107 00:07:59,760 --> 00:08:03,690 ‫What that means, it would be way too much for at this point of the course. 108 00:08:03,690 --> 00:08:06,330 ‫We're going to see what that means later on in the course. 109 00:08:06,330 --> 00:08:10,530 ‫Then we say that this method is void so it doesn't return anything. 110 00:08:10,530 --> 00:08:15,660 ‫We're going to see what that means once we're looking into methods and then this is the actual method, 111 00:08:15,660 --> 00:08:17,790 ‫we're going to see what methods are later on as well. 112 00:08:17,790 --> 00:08:23,940 ‫So basically we're saying, okay, this is the entry point of our program and once we run our program, 113 00:08:23,940 --> 00:08:27,930 ‫please run whatever code is inside of these curly brackets here. 114 00:08:27,930 --> 00:08:33,570 ‫And for now, what it does is it uses this console which is predefined code, which is inside of this 115 00:08:33,690 --> 00:08:40,440 ‫system namespace and it uses its own method called right line, which then writes onto the console. 116 00:08:40,440 --> 00:08:45,210 ‫So once you hover over this console here, it says represents the standard input output in error streams 117 00:08:45,210 --> 00:08:47,070 ‫for console applications. 118 00:08:47,250 --> 00:08:56,010 ‫So now if you run our program, we will see that it automatically opens up this little window and it 119 00:08:56,010 --> 00:08:58,020 ‫says Hello world here. 120 00:08:58,590 --> 00:09:02,220 ‫So this is what our software now does for us. 121 00:09:02,310 --> 00:09:03,840 ‫And where does it come from? 122 00:09:03,840 --> 00:09:07,200 ‫Well, it came from hello world bin debug dot net 5.0. 123 00:09:07,200 --> 00:09:07,950 ‫Hello World X. 124 00:09:08,400 --> 00:09:13,530 ‫Okay, so that file was executed for us and it said hello world. 125 00:09:13,620 --> 00:09:17,340 ‫So now instead of saying hello world, let's add another line. 126 00:09:17,340 --> 00:09:24,180 ‫So let's just copy this line here, let's add it underneath and say something like, Hello, Dennis. 127 00:09:24,270 --> 00:09:26,370 ‫In my case it's going to say Hello, Dennis. 128 00:09:26,370 --> 00:09:31,350 ‫And in your case, what I would like you to do is I would like you to change that, to say hello and 129 00:09:31,350 --> 00:09:32,280 ‫then your name. 130 00:09:33,040 --> 00:09:33,640 ‫Okay. 131 00:09:33,760 --> 00:09:36,640 ‫And then now it will say hello world in one line. 132 00:09:36,640 --> 00:09:38,980 ‫And in the second line it will say Hello, Dennis. 133 00:09:38,980 --> 00:09:43,270 ‫So let's run the software real quick and you see it says Hello World and one line. 134 00:09:43,270 --> 00:09:45,790 ‫And in the second line it says, Hello, Dennis. 135 00:09:46,420 --> 00:09:51,220 ‫Now what you can also see is that instead of this right line, you have these brackets. 136 00:09:51,220 --> 00:09:54,850 ‫Inside of those brackets, you have this string. 137 00:09:54,850 --> 00:10:01,840 ‫That's the official name of it, basically a piece of text where you need to surround it with quotation 138 00:10:01,840 --> 00:10:03,310 ‫marks, as you see here. 139 00:10:03,310 --> 00:10:07,240 ‫And then we have a closing bracket as well as a semicolon at the end. 140 00:10:07,330 --> 00:10:12,610 ‫And semicolon is very important in programming, at least in most programming languages. 141 00:10:12,610 --> 00:10:18,340 ‫There are some programming languages that are not using a semicolon at the end of each line, but in 142 00:10:18,340 --> 00:10:19,840 ‫C sharp it's required. 143 00:10:19,840 --> 00:10:24,220 ‫So we're basically saying, okay, this is where the statement ends. 144 00:10:24,220 --> 00:10:27,100 ‫So here we are finishing it with a semicolon. 145 00:10:27,840 --> 00:10:29,060 ‫So the same goes here. 146 00:10:29,070 --> 00:10:32,280 ‫We're finishing the statement and we're adding a semicolon. 147 00:10:32,310 --> 00:10:34,890 ‫This might look a little weird at the beginning, but no worries. 148 00:10:34,890 --> 00:10:37,380 ‫You're going to get a hang of it later on. 149 00:10:38,180 --> 00:10:41,450 ‫So now what you can also see is that there are a bunch of curly brackets. 150 00:10:41,450 --> 00:10:47,270 ‫So here this namespace hello world has a curly bracket and opening one here and the closing one down 151 00:10:47,270 --> 00:10:51,230 ‫there, which is automatically also marked once I mark one of them. 152 00:10:51,230 --> 00:10:56,090 ‫So it says, okay, this part is now my body. 153 00:10:56,090 --> 00:10:59,090 ‫So this is the part that is inside of me. 154 00:10:59,090 --> 00:11:06,440 ‫So here the class, all of this code here is inside of the Helloworld namespace and then this stuff 155 00:11:06,440 --> 00:11:09,710 ‫here is inside of the class program. 156 00:11:10,250 --> 00:11:15,500 ‫And then we have this method called Main and inside of it is that code here. 157 00:11:15,500 --> 00:11:21,230 ‫So at the left hand side you can even see these minuses here and you can collapse the entries, the 158 00:11:21,230 --> 00:11:24,020 ‫code by just pressing on them. 159 00:11:24,020 --> 00:11:25,340 ‫And this will then. 160 00:11:26,100 --> 00:11:28,710 ‫Shrink your code, but the code is still there. 161 00:11:29,580 --> 00:11:35,400 ‫Now, another very short, very interesting thing that I wanted to show you is that if you open the 162 00:11:35,400 --> 00:11:40,980 ‫folder in the file Explorer and you actually go to bin debug dot net five, you will find that there 163 00:11:40,980 --> 00:11:42,890 ‫is this helloworld exe file. 164 00:11:42,900 --> 00:11:47,970 ‫So if you click on that, it will also open the console. 165 00:11:48,570 --> 00:11:51,180 ‫But unfortunately it's closing straightaway. 166 00:11:51,190 --> 00:11:58,470 ‫So if you want to make sure that it stays open, then you need to add this line here which says console 167 00:11:58,470 --> 00:11:59,370 ‫dot read. 168 00:11:59,370 --> 00:12:04,830 ‫So what that will do is it will read the next character from the standard input stream. 169 00:12:06,120 --> 00:12:09,960 ‫And we also need to use these brackets because we're actually calling a method. 170 00:12:09,960 --> 00:12:14,520 ‫As I said, we're going to see what methods are later on and we need a semicolon in order to finish 171 00:12:14,520 --> 00:12:15,480 ‫this statement. 172 00:12:15,480 --> 00:12:22,680 ‫So now if you run this code, it will run as it did before, but it's going to stay open and let me 173 00:12:22,680 --> 00:12:29,460 ‫press a key, and then it will close, so to speak, even though in Visual Studio, by default, it 174 00:12:29,460 --> 00:12:32,640 ‫leaves this window open for us for debugging. 175 00:12:32,640 --> 00:12:35,850 ‫You can turn this off if you go to this setting here. 176 00:12:35,850 --> 00:12:40,170 ‫So tools, options, debugging automatically close to console with debugging stops. 177 00:12:40,230 --> 00:12:42,270 ‫So feel free to make that change. 178 00:12:42,270 --> 00:12:49,890 ‫But what's interesting now is if you go back to our hello world exa that's the window is now staying 179 00:12:49,890 --> 00:12:52,290 ‫open so it stays open. 180 00:12:52,290 --> 00:12:55,710 ‫And now once we press the key, it closes. 181 00:12:56,500 --> 00:12:56,790 ‫Okay. 182 00:12:56,800 --> 00:12:58,600 ‫So this is our software. 183 00:12:58,600 --> 00:13:05,320 ‫So now we wrote our own Excel file, and we can use this Excel file in order to impress our friends. 184 00:13:05,830 --> 00:13:06,340 ‫All right. 185 00:13:06,340 --> 00:13:08,260 ‫So that's it for this video. 186 00:13:08,290 --> 00:13:09,490 ‫See you in the next one.