1 00:00:00,570 --> 00:00:01,590 ‫Welcome back. 2 00:00:01,620 --> 00:00:05,880 ‫In the last video, you have learned how to write something onto the console. 3 00:00:05,880 --> 00:00:08,480 ‫And we have written our first Hello World Program. 4 00:00:08,490 --> 00:00:12,750 ‫And now let's go ahead and have a look at what this using means. 5 00:00:12,750 --> 00:00:17,220 ‫So we have used that in the last video and we simply had the code. 6 00:00:17,220 --> 00:00:20,250 ‫We didn't really have to write it ourselves. 7 00:00:20,250 --> 00:00:27,360 ‫And what you can see here is that those four lines are grayed out and that line here is not grayed out. 8 00:00:27,450 --> 00:00:35,160 ‫And that is because we use the system namespace in our code and you might wonder where is that? 9 00:00:35,160 --> 00:00:37,860 ‫Where do we use the namespace system? 10 00:00:37,860 --> 00:00:41,040 ‫And that is through the console. 11 00:00:41,040 --> 00:00:47,970 ‫So we have system console as a class which represents the standard input output in error streams for 12 00:00:47,970 --> 00:00:49,710 ‫console applications. 13 00:00:49,710 --> 00:00:52,860 ‫And that is exactly what we want to use. 14 00:00:52,860 --> 00:01:00,330 ‫So there is a class within the namespace system which is called console, and that class has multiple 15 00:01:00,330 --> 00:01:05,040 ‫methods and one of them is right line and another of them is read. 16 00:01:05,340 --> 00:01:09,780 ‫What methods are in detail is what we're going to cover later on. 17 00:01:09,780 --> 00:01:15,090 ‫But for now, as you can see, this static void main is a method itself. 18 00:01:15,090 --> 00:01:20,070 ‫So this one, the main is a method where we start our program. 19 00:01:20,160 --> 00:01:29,130 ‫So this is the starting point of our program and the console is a class which also has plenty of methods 20 00:01:29,130 --> 00:01:35,520 ‫and you can find them out by writing the name of the class, which is console and then dot and then 21 00:01:35,520 --> 00:01:37,590 ‫you find different methods. 22 00:01:37,590 --> 00:01:45,870 ‫So we have the method, for example, read, read, key, read line, and the methods are those little 23 00:01:45,870 --> 00:01:46,650 ‫boxes. 24 00:01:46,770 --> 00:01:48,570 ‫Then we have events. 25 00:01:48,960 --> 00:01:56,400 ‫In this case there is only the console key press event and then we have the properties which are those 26 00:01:56,400 --> 00:01:58,020 ‫tool icons here. 27 00:01:58,320 --> 00:02:02,100 ‫And properties is something that we're going to cover later on. 28 00:02:02,190 --> 00:02:08,100 ‫But what is important now is, for example, this right line and this right and read. 29 00:02:08,100 --> 00:02:13,800 ‫So if you want to find out more about what a method does, you can simply click on it and then you can 30 00:02:13,800 --> 00:02:14,910 ‫read the text here. 31 00:02:14,910 --> 00:02:16,950 ‫So it's explained pretty well. 32 00:02:16,950 --> 00:02:23,550 ‫And in our case we simply had this bright line that we have used here and we had the read. 33 00:02:23,550 --> 00:02:27,240 ‫But you can play around with those methods, you can check out what they do. 34 00:02:27,240 --> 00:02:34,410 ‫So we could, for example, reset the colors or we can simply change the color in general of our background 35 00:02:34,440 --> 00:02:39,330 ‫of the or of the foreground here, for example, for ground color. 36 00:02:39,660 --> 00:02:51,360 ‫And in here, we can set that by using the equal sign and then use the console color dot and let's go 37 00:02:51,360 --> 00:02:53,100 ‫with a blue. 38 00:02:53,460 --> 00:02:59,760 ‫So before that, our console color was always black, so the foreground color, but that alone will 39 00:02:59,760 --> 00:03:00,570 ‫not be enough. 40 00:03:00,570 --> 00:03:04,710 ‫And it's also important to have the right order. 41 00:03:04,710 --> 00:03:10,860 ‫So let's take that and put it at the top and now let's just try it. 42 00:03:10,920 --> 00:03:18,450 ‫So by the top, I mean at the top of our right line and as you can see here now, the text. 43 00:03:18,450 --> 00:03:20,760 ‫So the foreground is blue. 44 00:03:21,270 --> 00:03:26,640 ‫And if you want to change the color, you can easily do that by using a different color here. 45 00:03:26,640 --> 00:03:29,610 ‫So you have dark red, magenta, dark yellow. 46 00:03:29,610 --> 00:03:38,280 ‫So let's say I want to have the dark yellow as the foreground, color and console dot background color 47 00:03:40,320 --> 00:03:46,890 ‫being console color dot, let's say a gray. 48 00:03:47,490 --> 00:03:50,430 ‫So now we will have yellow text on gray. 49 00:03:50,430 --> 00:04:00,030 ‫And while that's not very beautiful and by the way, in order to make it a bit better, we need to clear 50 00:04:00,030 --> 00:04:00,630 ‫it as well. 51 00:04:00,630 --> 00:04:06,990 ‫So let's console dot clear 52 00:04:09,570 --> 00:04:10,920 ‫and now let's run it again. 53 00:04:12,920 --> 00:04:18,770 ‫And we are now we have this yellow text which we can barely read on the gray background. 54 00:04:18,860 --> 00:04:20,750 ‫So what is clear method does? 55 00:04:20,750 --> 00:04:26,900 ‫If you're wondering if you just simply click on it, you will find it out, clears the console buffer 56 00:04:26,900 --> 00:04:31,130 ‫and corresponds console window of display information. 57 00:04:31,130 --> 00:04:36,740 ‫So if we comment that out, so let's say we commented out just to see what happens if we don't have 58 00:04:36,740 --> 00:04:40,190 ‫that method in there, you can see that's what it does. 59 00:04:40,190 --> 00:04:48,710 ‫So only our text and well the corresponding area is colored, right. 60 00:04:48,710 --> 00:04:53,750 ‫So this console clear will take over the color for the whole console. 61 00:04:54,800 --> 00:04:55,130 ‫All right. 62 00:04:55,130 --> 00:04:58,790 ‫So that's what the console class can do. 63 00:04:58,790 --> 00:04:59,900 ‫It can do a lot more. 64 00:04:59,900 --> 00:05:08,510 ‫But those were examples of properties and these are examples of methods and all of that is within system 65 00:05:08,510 --> 00:05:09,770 ‫dot console. 66 00:05:09,770 --> 00:05:16,190 ‫By the way, if we get rid of all those console methods and properties, you can see that using system 67 00:05:16,190 --> 00:05:17,420 ‫is grayed out as well. 68 00:05:17,420 --> 00:05:24,530 ‫So now it's not used at all, but way with the minus and plus you can reduce the whole area. 69 00:05:24,530 --> 00:05:29,090 ‫So those whole five lines, you can reduce them to one line. 70 00:05:29,600 --> 00:05:33,140 ‫But if we now use the console. 71 00:05:34,410 --> 00:05:36,120 ‫It's coloured white again. 72 00:05:36,180 --> 00:05:44,010 ‫So let's get rid of those musings and you will see that the console suddenly returns errors. 73 00:05:44,010 --> 00:05:48,900 ‫So it says it doesn't know the console because it doesn't exist in the current context. 74 00:05:48,900 --> 00:05:53,490 ‫So in order to add it, we simply click on it. 75 00:05:53,490 --> 00:05:58,350 ‫So let's click on the error and then show potential fixes. 76 00:05:58,350 --> 00:06:04,380 ‫Or you can also get that with old enter and then it will provide you with different solutions. 77 00:06:04,380 --> 00:06:07,740 ‫So for example, you could use system console. 78 00:06:07,830 --> 00:06:11,790 ‫So by that system, that console, that will work. 79 00:06:11,790 --> 00:06:18,750 ‫But it's much easier to not only you add the system to one of them because we would have to add them 80 00:06:18,750 --> 00:06:22,170 ‫to every single time that we want to use the console. 81 00:06:22,170 --> 00:06:29,850 ‫It's much easier to simply import the namespace by adding using system. 82 00:06:30,120 --> 00:06:30,750 ‫All right. 83 00:06:30,750 --> 00:06:36,510 ‫So as you can see here, now, we have at the top using system and our console is green again, which 84 00:06:36,510 --> 00:06:38,370 ‫means it exists. 85 00:06:38,370 --> 00:06:42,750 ‫So this class exists and it's known in the current context. 86 00:06:42,750 --> 00:06:46,650 ‫So this year system is a namespace and it has a class called console. 87 00:06:46,650 --> 00:06:47,940 ‫We understand that already. 88 00:06:47,940 --> 00:06:51,630 ‫But now as you can see, there is a namespace called Helloworld. 89 00:06:51,630 --> 00:06:59,250 ‫So whenever we create our own code, we can use that as a namespace as well in order to access its methods 90 00:06:59,250 --> 00:07:00,180 ‫and properties. 91 00:07:00,300 --> 00:07:05,070 ‫But that's something that's going to be relevant much later in the course. 92 00:07:05,070 --> 00:07:07,440 ‫So let's just keep it at that. 93 00:07:07,440 --> 00:07:10,140 ‫And now you see what this using is for. 94 00:07:10,170 --> 00:07:16,410 ‫You can understand a bit better what system is about, what the namespace is about, and how to play 95 00:07:16,410 --> 00:07:18,840 ‫around with your console colors. 96 00:07:18,840 --> 00:07:24,600 ‫By the way, I wouldn't recommend to use those colours because they don't look great and you can simply 97 00:07:24,600 --> 00:07:27,360 ‫play around with different colours that you prefer. 98 00:07:27,360 --> 00:07:34,260 ‫And I'm just going to comment out those two lines and at the same time I'm going to comment about console 99 00:07:34,260 --> 00:07:35,370 ‫dot clear. 100 00:07:35,370 --> 00:07:40,710 ‫By the way, you can play around with the order just to see what happens if you do that later on in 101 00:07:40,710 --> 00:07:41,370 ‫the code. 102 00:07:41,370 --> 00:07:45,600 ‫And in this order that we have here, everything works fine. 103 00:07:46,110 --> 00:07:46,530 ‫Great. 104 00:07:46,530 --> 00:07:53,940 ‫So see you in the next video where we are going to have a look at beta types and variables.