WEBVTT 1 00:00:06.153 --> 00:00:09.856 Game Basics Installing Visual Studio and Intro to Programming 2 00:00:27.457 --> 00:00:29.059 Hello everyone 3 00:00:29.059 --> 00:00:33.998 I'm Lee Yeong-hoon, and I'm in charge of this C#-based object-oriented programming lecture 4 00:00:33.998 --> 00:00:35.867 The course will cover 5 00:00:35.867 --> 00:00:39.430 installing Visual Studio and programming basics, 6 00:00:39.430 --> 00:00:41.432 data types and variables, 7 00:00:41.432 --> 00:00:43.215 conditional statements and loops, 8 00:00:43.215 --> 00:00:45.405 and functions and classes, 9 00:00:45.405 --> 00:00:47.980 in that order 10 00:00:47.980 --> 00:00:50.357 In this lesson, we will 11 00:00:50.357 --> 00:00:54.099 install Visual Studio, an integrated development environment, 12 00:00:54.099 --> 00:00:56.836 learn basic programming concepts, 13 00:00:56.836 --> 00:00:58.703 and study C# fundamentals 14 00:00:59.183 --> 00:01:02.965 Installing Visual Studio Printing Hello World 15 00:01:05.010 --> 00:01:09.095 Today, we will install Visual Studio, 16 00:01:09.095 --> 00:01:12.180 try simple coding, 17 00:01:12.180 --> 00:01:16.927 and also discuss the overall 18 00:01:16.927 --> 00:01:19.059 development process 19 00:01:19.059 --> 00:01:23.295 Let's install Visual Studio from Google 20 00:01:23.295 --> 00:01:24.779 Let's search 21 00:01:24.779 --> 00:01:26.346 Visual Studio 22 00:01:28.910 --> 00:01:31.015 There's version 2022, 23 00:01:31.015 --> 00:01:33.664 so you can use this version 24 00:01:33.664 --> 00:01:35.300 Even for Unity, 25 00:01:35.300 --> 00:01:40.099 we're using their version 2022 26 00:01:40.099 --> 00:01:43.467 So here, we see many things 27 00:01:43.467 --> 00:01:46.419 And we have Community 2022 28 00:01:46.419 --> 00:01:49.009 This is the free version 29 00:01:49.009 --> 00:01:51.690 So let's use this 30 00:01:51.690 --> 00:01:53.527 Over to this side, 31 00:01:53.527 --> 00:01:56.779 we're seeing some downloads 32 00:01:56.779 --> 00:01:58.811 All done 33 00:01:58.811 --> 00:02:02.428 If it doesn't work, click here 34 00:02:02.428 --> 00:02:05.300 Select Visual Studio Setup 35 00:02:05.300 --> 00:02:07.673 Now we can install through 36 00:02:07.673 --> 00:02:08.918 Visual Studio Installer 37 00:02:11.068 --> 00:02:13.537 So let's continue installing 38 00:02:15.889 --> 00:02:17.922 This may take a while 39 00:02:17.922 --> 00:02:20.599 based on your internet speed 40 00:02:20.599 --> 00:02:22.667 Let's wait a bit and continue 41 00:02:30.341 --> 00:02:33.319 To install Visual Studio, 42 00:02:33.319 --> 00:02:37.833 this Installer works like a launcher 43 00:02:37.833 --> 00:02:40.665 Sao this has expansions 44 00:02:40.665 --> 00:02:43.920 that we can add to Visual Studio 45 00:02:43.920 --> 00:02:46.070 for our programming 46 00:02:46.070 --> 00:02:47.861 Before we begin, 47 00:02:47.861 --> 00:02:49.950 we need to check 48 00:02:49.950 --> 00:02:51.889 this .NET Desktop Programming 49 00:02:51.889 --> 00:02:54.120 And down here, 50 00:02:54.120 --> 00:02:57.597 you'll see Game Development with Unity 51 00:02:57.597 --> 00:02:59.094 Let's check this as well 52 00:03:01.046 --> 00:03:07.446 So again, check for .Net Desktop 53 00:03:07.446 --> 00:03:09.507 and also this Game Development 54 00:03:09.507 --> 00:03:11.770 Check for these two 55 00:03:11.770 --> 00:03:14.122 Here, we also have C++ 56 00:03:14.122 --> 00:03:16.511 If you're using Unreal, 57 00:03:16.511 --> 00:03:18.870 you can also check this 58 00:03:18.870 --> 00:03:20.962 Next, to bottom right, 59 00:03:20.962 --> 00:03:22.422 click Install 60 00:03:23.699 --> 00:03:27.081 This will download 61 00:03:27.081 --> 00:03:28.999 all the necessary information 62 00:03:31.230 --> 00:03:33.477 Now that this is done, 63 00:03:39.220 --> 00:03:41.257 it will automatically open 64 00:03:41.257 --> 00:03:42.957 We had this box ticked, 65 00:03:42.957 --> 00:03:44.719 so that it opens right away 66 00:03:44.719 --> 00:03:47.550 So now we have this 67 00:03:47.550 --> 00:03:50.268 Create an account and log in 68 00:03:50.268 --> 00:03:53.125 Then this will continue to be free 69 00:03:53.125 --> 00:03:56.199 It's also free for the first month, with the trial version 70 00:03:56.199 --> 00:03:58.672 For now, I will skip 71 00:03:58.672 --> 00:04:00.366 and continue 72 00:04:02.168 --> 00:04:04.007 So you can select 73 00:04:04.007 --> 00:04:06.016 the theme that you like 74 00:04:06.016 --> 00:04:08.185 I will keep the dark mode 75 00:04:13.928 --> 00:04:16.606 Now, for the Visual Studio, 76 00:04:16.606 --> 00:04:19.321 first, through the Visual Studio Installer, 77 00:04:19.321 --> 00:04:20.848 Click on M for Modify 78 00:04:20.848 --> 00:04:24.814 This allows us to add more features, 79 00:04:24.814 --> 00:04:26.165 or remove any 80 00:04:26.165 --> 00:04:28.441 You can untick the box 81 00:04:28.441 --> 00:04:29.850 to remove it 82 00:04:29.850 --> 00:04:34.167 That's how you manage these 83 00:04:34.167 --> 00:04:35.691 Now that we no longer need the Installer, 84 00:04:35.691 --> 00:04:37.950 I’ll go ahead and close it 85 00:04:37.950 --> 00:04:42.009 Once that’s done, Visual Studio should open like this 86 00:04:42.009 --> 00:04:44.509 You can see various options here 87 00:04:44.509 --> 00:04:47.990 We’re going to create a new project, 88 00:04:47.990 --> 00:04:49.346 so let’s click on that 89 00:04:51.859 --> 00:04:55.614 ou’ll see a variety of templates, 90 00:04:55.614 --> 00:04:57.479 but we won’t use all of them 91 00:04:57.479 --> 00:04:59.117 Here, you’ll find the language options 92 00:04:59.117 --> 00:05:02.389 We’ll select C# 93 00:05:02.389 --> 00:05:05.646 Next, on the far right, you’ll see a format option 94 00:05:05.646 --> 00:05:09.472 We’ll use the Console app 95 00:05:09.472 --> 00:05:11.794 After selecting Console, 96 00:05:11.794 --> 00:05:14.528 two options will appear 97 00:05:14.528 --> 00:05:18.238 We’ll choose .NET Framework 98 00:05:18.238 --> 00:05:20.959 Once that’s selected, 99 00:05:20.959 --> 00:05:22.336 click the Next button 100 00:05:24.700 --> 00:05:27.405 Now, we can configure our new project 101 00:05:27.405 --> 00:05:29.146 This window shows 102 00:05:29.146 --> 00:05:30.341 the project 103 00:05:30.341 --> 00:05:32.690 and solution names 104 00:05:32.690 --> 00:05:34.548 It’s important to understand 105 00:05:34.548 --> 00:05:35.932 what a solution 106 00:05:35.932 --> 00:05:38.666 and a project are 107 00:05:38.666 --> 00:05:42.100 A solution is a broader concept, 108 00:05:42.100 --> 00:05:44.518 and a project is 109 00:05:44.518 --> 00:05:47.161 part of the solution 110 00:05:47.161 --> 00:05:49.167 So basically, 111 00:05:49.167 --> 00:05:51.608 if you’re only making one project, 112 00:05:51.608 --> 00:05:53.333 you can use the same name 113 00:05:53.333 --> 00:05:56.206 for both the solution and the project 114 00:05:56.206 --> 00:05:57.908 But if you’re managing multiple projects 115 00:05:57.908 --> 00:05:59.990 under one solution, 116 00:05:59.990 --> 00:06:02.520 you can give them different names 117 00:06:02.520 --> 00:06:05.738 Let’s create a project 118 00:06:05.738 --> 00:06:06.851 to print Hello World 119 00:06:06.851 --> 00:06:10.701 When people first learn coding, 120 00:06:10.701 --> 00:06:14.638 printing Hello World 121 00:06:14.638 --> 00:06:15.624 is usually the first thing they do 122 00:06:15.624 --> 00:06:18.995 If you can do that, you’re already halfway there! 123 00:06:18.995 --> 00:06:21.350 Let’s create a project 124 00:06:21.350 --> 00:06:23.245 to print Hello World 125 00:06:27.496 --> 00:06:29.246 For the solution name, 126 00:06:29.246 --> 00:06:31.315 I’ll use Coding 127 00:06:32.790 --> 00:06:34.330 That's it 128 00:06:34.330 --> 00:06:37.277 Now, for the location 129 00:06:37.277 --> 00:06:39.059 We’re talking about 130 00:06:39.059 --> 00:06:42.296 where to save this project and solution 131 00:06:42.296 --> 00:06:44.170 You can leave it as it is, 132 00:06:44.170 --> 00:06:49.215 but I’ll go ahead and put it in a new folder 133 00:06:49.215 --> 00:06:51.456 You’ll see 134 00:06:51.456 --> 00:06:53.844 that I’ve created a folder called Project, 135 00:06:53.844 --> 00:06:57.246 so I’ll save it there 136 00:06:59.299 --> 00:07:01.178 After setting that, 137 00:07:01.178 --> 00:07:03.147 click the Create button 138 00:07:09.918 --> 00:07:11.464 You’ll see 139 00:07:11.464 --> 00:07:14.100 the project being created 140 00:07:14.100 --> 00:07:16.658 If you open the folder, 141 00:07:19.058 --> 00:07:24.128 You’ll find that 142 00:07:24.128 --> 00:07:27.371 a Hello World project folder 143 00:07:27.371 --> 00:07:29.529 is created under 144 00:07:29.529 --> 00:07:31.767 the Coding folder 145 00:07:31.767 --> 00:07:36.538 There’s also a file named Coding.sln 146 00:07:36.538 --> 00:07:40.135 This is the solution file 147 00:07:40.135 --> 00:07:42.371 So here is the solution file, 148 00:07:42.371 --> 00:07:44.080 and the Hello World project under it 149 00:07:44.080 --> 00:07:45.700 That's how it works 150 00:07:45.700 --> 00:07:48.268 Now that we understand the structure, 151 00:07:50.159 --> 00:07:52.735 let’s open the Visual Studio project 152 00:07:52.735 --> 00:07:54.499 Here, 153 00:07:54.499 --> 00:07:57.396 you should see the Solution Explorer 154 00:07:57.396 --> 00:07:59.646 If you don’t see it, 155 00:07:59.646 --> 00:08:01.850 go to the top bar and click 156 00:08:01.850 --> 00:08:05.107 on Window Layout Reset 157 00:08:05.107 --> 00:08:07.146 Click on it, 158 00:08:07.146 --> 00:08:08.924 and you'll see it 159 00:08:08.924 --> 00:08:10.574 Now, in the Solution Explorer, 160 00:08:10.574 --> 00:08:12.397 you’ll see “Coding” as the solution, 161 00:08:12.397 --> 00:08:13.935 and below that, 162 00:08:13.935 --> 00:08:17.182 the Hello World project 163 00:08:17.182 --> 00:08:19.013 The file we’re working 164 00:08:19.013 --> 00:08:23.199 with now is called Program.cs 165 00:08:23.199 --> 00:08:26.157 Let’s go ahead and print Hello World 166 00:08:26.157 --> 00:08:28.850 I know we’re still beginners, but here’s what we do 167 00:08:28.850 --> 00:08:31.935 You’ll see the word Main 168 00:08:31.935 --> 00:08:33.817 This is the function we’ll use 169 00:08:33.817 --> 00:08:38.040 At Main, we have the curly braces 170 00:08:38.040 --> 00:08:39.224 Inside the curly braces 171 00:08:39.224 --> 00:08:42.967 is called the scope 172 00:08:42.967 --> 00:08:46.420 I’ll call it a space for now, 173 00:08:46.420 --> 00:08:49.612 because it occupies a space like so 174 00:08:49.612 --> 00:08:53.207 You’ll see these scopes here as well 175 00:08:53.207 --> 00:08:58.349 Inside this scope under Main, 176 00:08:58.349 --> 00:09:00.304 you can automatically indent 177 00:09:00.304 --> 00:09:02.814 by pressing the Tab key 178 00:09:02.814 --> 00:09:04.510 Now, type this 179 00:09:04.510 --> 00:09:05.865 Console 180 00:09:07.469 --> 00:09:09.471 And a period 181 00:09:09.471 --> 00:09:11.364 It will complete it for you 182 00:09:11.364 --> 00:09:13.870 WriteLine 183 00:09:13.870 --> 00:09:15.742 Press Tab to get this 184 00:09:15.742 --> 00:09:17.129 And open a parenthesis 185 00:09:18.615 --> 00:09:22.239 And add quotation marks 186 00:09:22.239 --> 00:09:25.147 Let's type Hello World 187 00:09:31.068 --> 00:09:33.061 There we have it 188 00:09:33.061 --> 00:09:35.820 Let's save it 189 00:09:35.820 --> 00:09:40.930 To save, use Ctrl+S 190 00:09:40.930 --> 00:09:43.392 For saving all files, 191 00:09:43.392 --> 00:09:45.112 you can use Ctrl+Shift+S 192 00:09:45.112 --> 00:09:48.300 Both Ctrl+S and Ctrl+Shift+S 193 00:09:48.300 --> 00:09:50.145 can save the file 194 00:09:50.145 --> 00:09:53.139 This is our source file, 195 00:09:53.139 --> 00:09:55.038 or a source code 196 00:09:55.038 --> 00:09:57.910 This is where we write our codes 197 00:09:57.910 --> 00:09:59.857 Let's run it 198 00:09:59.857 --> 00:10:02.358 After saving, 199 00:10:02.358 --> 00:10:04.279 look at the top for the button 200 00:10:04.279 --> 00:10:07.019 Or if you look here, there is an option 201 00:10:07.019 --> 00:10:08.389 called Build and Debug 202 00:10:08.389 --> 00:10:11.750 When you build, you make the program ready to run 203 00:10:11.750 --> 00:10:14.386 The build process 204 00:10:14.386 --> 00:10:18.573 turns your source code 205 00:10:18.573 --> 00:10:22.219 into an executable file 206 00:10:22.219 --> 00:10:24.270 So, let’s try this 207 00:10:24.270 --> 00:10:27.123 Let's try building it now 208 00:10:27.123 --> 00:10:29.644 Click on Build, and the process will start 209 00:10:29.644 --> 00:10:30.668 It's building 210 00:10:32.729 --> 00:10:33.889 The build is complete, 211 00:10:33.889 --> 00:10:38.398 and you’ll see a message saying, Build 1 succeeded 212 00:10:38.398 --> 00:10:41.074 Then, there’s the Debug section 213 00:10:41.074 --> 00:10:42.979 You’ll find options 214 00:10:42.979 --> 00:10:45.114 to either to start debugging 215 00:10:45.114 --> 00:10:47.940 or to start without debugging 216 00:10:47.940 --> 00:10:50.466 You can use the shortcuts F5 217 00:10:50.466 --> 00:10:52.140 or Ctrl+F5 to do these 218 00:10:52.140 --> 00:10:54.233 It's the same thing here 219 00:10:54.233 --> 00:10:56.623 This will start the program with debugging enabled 220 00:10:56.623 --> 00:10:58.228 Let’s try running it with this 221 00:10:58.228 --> 00:11:00.940 Here’s what happens 222 00:11:00.940 --> 00:11:03.640 when you press Ctrl+F5 223 00:11:03.640 --> 00:11:05.318 A black console window will open up 224 00:11:05.318 --> 00:11:08.478 This window is called the console window 225 00:11:08.478 --> 00:11:11.600 In the console, you should see 226 00:11:11.600 --> 00:11:13.227 Hello World displayed 227 00:11:15.700 --> 00:11:18.342 Now, let’s close the console window 228 00:11:18.342 --> 00:11:20.852 This is how the structure is set up 229 00:11:20.852 --> 00:11:25.380 In the code, there is a line that says using, 230 00:11:25.380 --> 00:11:28.793 which means we are using 231 00:11:28.793 --> 00:11:30.367 some system functionality 232 00:11:30.367 --> 00:11:32.409 There’s also the term namespace, 233 00:11:32.409 --> 00:11:35.652 which has name and space in its term, right? 234 00:11:35.652 --> 00:11:39.214 It stands for creating a container or space for code 235 00:11:39.214 --> 00:11:40.649 Let me explicate 236 00:11:40.649 --> 00:11:43.140 Inside the namespace, 237 00:11:43.140 --> 00:11:45.381 you will see the class Program 238 00:11:45.381 --> 00:11:47.224 Hover over Program to see its details 239 00:11:47.224 --> 00:11:49.039 Here at class, 240 00:11:49.039 --> 00:11:51.780 the Program class is the only class here, 241 00:11:51.780 --> 00:11:55.195 but in the upper part of the screen, you’ll notice 242 00:11:55.195 --> 00:11:57.514 HelloWorld.Program written 243 00:11:57.514 --> 00:11:59.762 So the meaning of this namespace 244 00:11:59.762 --> 00:12:01.580 is that it holds a space, 245 00:12:01.580 --> 00:12:04.554 and its keywords 246 00:12:04.554 --> 00:12:06.457 that belong to that space 247 00:12:06.457 --> 00:12:08.596 are part of the namespace 248 00:12:10.480 --> 00:12:13.530 Now, let’s take a closer look 249 00:12:13.530 --> 00:12:16.050 The Main function, 250 00:12:16.050 --> 00:12:18.649 which we referred to earlier, 251 00:12:18.649 --> 00:12:21.757 is where the program begins 252 00:12:21.757 --> 00:12:24.939 The Main function is known as the entry point 253 00:12:24.939 --> 00:12:26.565 of the C# application 254 00:12:26.565 --> 00:12:28.519 Let me explain about application 255 00:12:28.519 --> 00:12:31.157 Have you heard about app? 256 00:12:31.157 --> 00:12:32.999 App stands for application 257 00:12:32.999 --> 00:12:35.239 We're familiar with app 258 00:12:35.239 --> 00:12:36.726 An application is referring 259 00:12:36.726 --> 00:12:39.098 to a software application 260 00:12:39.098 --> 00:12:41.498 When we create a program and run it, 261 00:12:41.498 --> 00:12:44.067 it begins to execute 262 00:12:44.067 --> 00:12:45.896 in a running process 263 00:12:45.896 --> 00:12:47.448 So, when you run the program, 264 00:12:47.448 --> 00:12:50.053 it's the first function that gets called 265 00:12:50.053 --> 00:12:51.530 That's how you can understand it 266 00:12:51.530 --> 00:12:54.027 That’s why it’s referred to as the entry point 267 00:12:54.027 --> 00:12:57.977 In C#, there is exactly one entry point 268 00:12:57.977 --> 00:13:00.075 So, here, the Main function 269 00:13:00.075 --> 00:13:01.940 serves as the entry point 270 00:13:01.940 --> 00:13:04.909 If we look at the details, 271 00:13:04.909 --> 00:13:06.873 you’ll see the word static, 272 00:13:06.873 --> 00:13:08.521 followed by void Main, 273 00:13:08.521 --> 00:13:09.914 Here you’ll also see the word string, 274 00:13:09.914 --> 00:13:11.808 which means a string, or text 275 00:13:11.808 --> 00:13:12.432 String 276 00:13:12.432 --> 00:13:15.484 And this means it’s an array 277 00:13:15.484 --> 00:13:17.772 And args 278 00:13:17.772 --> 00:13:20.889 represents parameters 279 00:13:20.889 --> 00:13:23.648 If you hover over it, you’ll see it says parameters 280 00:13:23.648 --> 00:13:25.849 We’ll dive deeper into functions later, 281 00:13:25.849 --> 00:13:27.633 when we get a chance, 282 00:13:27.633 --> 00:13:30.219 but for now, let’s test it briefly 283 00:13:30.219 --> 00:13:32.660 As you can see, there is the args variable 284 00:13:32.660 --> 00:13:36.366 We’ll differentiate between when args exists and when it doesn’t 285 00:13:36.366 --> 00:13:39.299 We will output different results based on that 286 00:13:39.299 --> 00:13:41.281 So here, I’ll write 287 00:13:41.281 --> 00:13:43.149 something like this 288 00:13:43.149 --> 00:13:51.619 If there is a value in args, 289 00:13:51.619 --> 00:13:54.113 I will process it accordingly 290 00:13:54.113 --> 00:13:56.524 To check whether there is a value or not, 291 00:13:56.524 --> 00:13:58.717 some consideration is required, right? 292 00:13:58.717 --> 00:14:01.299 That there is a value means this 293 00:14:01.299 --> 00:14:04.988 To check if a value exists in args, 294 00:14:04.988 --> 00:14:08.046 we check if its length is greater than 0 295 00:14:08.046 --> 00:14:09.157 If it is, I will express it this way 296 00:14:09.157 --> 00:14:15.084 If there is a value and the length is greater than 0… 297 00:14:15.084 --> 00:14:18.798 This will indicate that there is a value 298 00:14:18.798 --> 00:14:23.087 If the value exists, we will output 299 00:14:23.087 --> 00:14:24.087 the value from args 300 00:14:24.087 --> 00:14:25.607 Otherwise, we will output 301 00:14:25.607 --> 00:14:27.099 Hello World 302 00:14:27.099 --> 00:14:33.267 So if there is a value, 303 00:14:35.460 --> 00:14:37.370 I want to output the first value in args 304 00:14:37.370 --> 00:14:40.270 Actually, in programming, 305 00:14:40.270 --> 00:14:43.219 we often talk about input and output 306 00:14:43.219 --> 00:14:45.720 Right now, this is written as Write, 307 00:14:45.720 --> 00:14:49.031 Console.Write, which means output 308 00:14:49.031 --> 00:14:51.034 But there is also input 309 00:14:51.034 --> 00:14:54.442 In the console, there is Read 310 00:14:54.442 --> 00:14:56.468 There is Read, 311 00:14:56.468 --> 00:14:59.539 ReadKey, and ReadLine 312 00:14:59.539 --> 00:15:00.871 By using these, 313 00:15:00.871 --> 00:15:03.484 we can read the data 314 00:15:03.484 --> 00:15:05.430 entered from the keyboard 315 00:15:05.430 --> 00:15:08.619 Just remember this for now 316 00:15:08.619 --> 00:15:11.891 For now, we’ll focus on output only 317 00:15:11.891 --> 00:15:15.098 So let’s output it here 318 00:15:15.098 --> 00:15:16.282 If that's not the case, 319 00:15:17.639 --> 00:15:21.066 or if there is no value in args, 320 00:15:21.066 --> 00:15:25.930 we’ll output Hello World 321 00:15:25.930 --> 00:15:27.667 Let’s do this now 322 00:15:27.667 --> 00:15:30.011 This will be covered later, 323 00:15:30.011 --> 00:15:32.762 when we learn about conditionals 324 00:15:32.762 --> 00:15:35.235 But for now, let’s keep it simple 325 00:15:35.235 --> 00:15:36.617 and try it out 326 00:15:36.617 --> 00:15:38.565 If you write if here, 327 00:15:38.565 --> 00:15:40.335 it will automatically 328 00:15:40.335 --> 00:15:42.390 generate the code for you 329 00:15:42.390 --> 00:15:43.678 Let's write it like that 330 00:15:46.820 --> 00:15:50.356 You add a condition here, 331 00:15:50.356 --> 00:15:55.178 and this is for comparison 332 00:15:55.178 --> 00:15:58.300 So these two equal signs mean equal to 333 00:15:58.300 --> 00:16:00.902 It checks if it equals 0 334 00:16:00.902 --> 00:16:03.879 But what I want is, If it’s greater than 0 335 00:16:03.879 --> 00:16:08.170 So you can write this for that 336 00:16:08.170 --> 00:16:11.253 Now let’s proceed with this 337 00:16:11.253 --> 00:16:14.820 If you hold the Alt key and press the arrow keys, 338 00:16:14.820 --> 00:16:19.387 the line with the cursor here 339 00:16:19.387 --> 00:16:21.579 moves like so 340 00:16:21.579 --> 00:16:23.235 You can also group this together 341 00:16:23.235 --> 00:16:25.248 So, press the shift key 342 00:16:25.248 --> 00:16:27.321 and select the block like this, 343 00:16:27.321 --> 00:16:30.136 then press the alt key and move it up and down 344 00:16:30.136 --> 00:16:31.940 It will move together 345 00:16:31.940 --> 00:16:33.199 Using these, 346 00:16:33.199 --> 00:16:36.045 it would be great to code faster 347 00:16:36.055 --> 00:16:38.219 I will press the alt key and move this up 348 00:16:38.219 --> 00:16:39.957 And if not, then this will be 349 00:16:39.957 --> 00:16:43.181 called else 350 00:16:43.181 --> 00:16:45.318 You can write it like this 351 00:16:48.396 --> 00:16:51.040 Let’s try to output this 352 00:16:51.040 --> 00:16:54.738 Here, we will use Console.WriteLine as it is 353 00:17:00.870 --> 00:17:04.139 This is the first value of args 354 00:17:04.139 --> 00:17:05.327 You can write it like this 355 00:17:05.327 --> 00:17:09.278 The first value in an array starts from 0 356 00:17:09.278 --> 00:17:10.614 Since we haven’t 357 00:17:10.614 --> 00:17:13.074 learned things like arrays yet, 358 00:17:13.074 --> 00:17:16.070 you might not understand it well, but let’s try it out 359 00:17:16.070 --> 00:17:18.419 So, this array actually 360 00:17:18.419 --> 00:17:19.912 refers to a list 361 00:17:19.912 --> 00:17:23.857 It means the first item in the list 362 00:17:25.758 --> 00:17:29.935 In computer programming, 363 00:17:29.935 --> 00:17:33.569 we start counting from 0 364 00:17:33.569 --> 00:17:37.430 This is called zero-based indexing 365 00:17:37.430 --> 00:17:38.835 So when it says 0, 366 00:17:38.835 --> 00:17:43.488 it means it starts from 0 367 00:17:43.488 --> 00:17:45.469 Therefore, the length is greater than 0 368 00:17:45.469 --> 00:17:48.887 If there’s one, it would be 1 369 00:17:48.887 --> 00:17:51.455 The first item is 0 370 00:17:51.455 --> 00:17:53.780 You can think of it like that 371 00:17:53.780 --> 00:17:55.497 Let's save this 372 00:17:55.497 --> 00:17:59.048 and try running it 373 00:17:59.048 --> 00:18:02.670 Then, of course, Hello World will be printed 374 00:18:02.670 --> 00:18:05.061 This is because, 375 00:18:05.061 --> 00:18:07.580 when we start this program, 376 00:18:07.580 --> 00:18:10.255 since no parameters were given, 377 00:18:10.255 --> 00:18:11.819 It will show this 378 00:18:11.819 --> 00:18:13.995 Now, to test this, 379 00:18:13.995 --> 00:18:18.022 We should check the generated executable, right? 380 00:18:18.022 --> 00:18:21.717 The current folder is here 381 00:18:21.717 --> 00:18:23.726 When you go to this folder, you’ll see the program 382 00:18:23.726 --> 00:18:25.914 To this open file, 383 00:18:25.914 --> 00:18:29.021 right-click the open file, 384 00:18:29.021 --> 00:18:31.619 and you’ll see an option to Open Parent Folder 385 00:18:31.619 --> 00:18:34.675 Click this to go there 386 00:18:34.675 --> 00:18:37.014 Right behind here, 387 00:18:37.014 --> 00:18:41.179 you can enter the Hello World folder and look 388 00:18:41.179 --> 00:18:44.225 There’s a folder called bin 389 00:18:44.225 --> 00:18:46.176 This stands for binary 390 00:18:46.176 --> 00:18:47.901 Inside the bin folder, 391 00:18:47.901 --> 00:18:48.953 you’ll see a Debug folder 392 00:18:48.953 --> 00:18:50.974 It's Debug because of this 393 00:18:50.974 --> 00:18:53.445 It says Debug here 394 00:18:53.445 --> 00:18:58.060 If you change it to Release and build, 395 00:18:58.060 --> 00:19:01.688 like this, build, 396 00:19:01.688 --> 00:19:05.325 a Release folder will also be created 397 00:19:07.266 --> 00:19:10.855 But I will keep it as Debug 398 00:19:10.855 --> 00:19:16.300 Debug is selected, and the build shortcut is Ctrl+B 399 00:19:16.300 --> 00:19:19.097 So, you can press Ctrl+B 400 00:19:19.097 --> 00:19:21.439 This will build the project 401 00:19:26.043 --> 00:19:27.266 It seems a bit strange 402 00:19:27.266 --> 00:19:28.054 Let’s do it like this 403 00:19:30.024 --> 00:19:32.827 So we will build like this 404 00:19:32.827 --> 00:19:34.438 Let’s delete everything and try again 405 00:19:37.766 --> 00:19:40.315 When you build, the file will be created again 406 00:19:40.315 --> 00:19:41.738 Here it is 407 00:19:41.738 --> 00:19:45.372 Now, let’s look 408 00:19:45.372 --> 00:19:47.223 at the file extension 409 00:19:47.223 --> 00:19:49.917 You’ll see that it creates an exe file 410 00:19:49.917 --> 00:19:53.300 If you double-click it, 411 00:19:53.300 --> 00:19:55.059 Hello World should be printed 412 00:19:55.059 --> 00:19:57.136 But it happens too quickly 413 00:19:57.136 --> 00:19:58.846 for us to see anything 414 00:19:58.846 --> 00:20:00.496 If you right-click here, 415 00:20:00.496 --> 00:20:02.533 I have an option called Open Terminal 416 00:20:02.533 --> 00:20:04.303 Some of you might not see this, 417 00:20:04.303 --> 00:20:06.139 that could be the case 418 00:20:06.139 --> 00:20:07.353 So let me show you how 419 00:20:07.353 --> 00:20:11.459 Here, you’ll see a search button, right? 420 00:20:11.459 --> 00:20:15.227 Type cmd You’ll find something called Command Prompt 421 00:20:15.227 --> 00:20:17.531 This is also called a console 422 00:20:17.531 --> 00:20:20.660 Click it to open the window 423 00:20:20.660 --> 00:20:24.221 You’ll see that black window we saw earlier, right? 424 00:20:24.221 --> 00:20:28.019 Next, we are going to move to this folder 425 00:20:28.019 --> 00:20:30.344 Click here at the top 426 00:20:30.344 --> 00:20:35.739 This will give you the full absolute path of this folder 427 00:20:35.739 --> 00:20:38.239 I’ll copy this 428 00:20:38.239 --> 00:20:40.281 Now, copy it 429 00:20:40.281 --> 00:20:44.798 Then, go back to the console 430 00:20:44.798 --> 00:20:46.928 There’s a command called Change Directory, 431 00:20:46.928 --> 00:20:48.690 which is cd 432 00:20:48.690 --> 00:20:49.791 Change Directory 433 00:20:49.791 --> 00:20:53.246 In programming, we often refer to folders as directories 434 00:20:53.246 --> 00:20:55.464 We’ll move to this directory 435 00:20:55.464 --> 00:20:58.344 So, type Change Directory, then leave a space, 436 00:20:58.344 --> 00:21:01.339 Then paste the part we just copied 437 00:21:01.339 --> 00:21:04.705 Right-click to paste what we have 438 00:21:04.705 --> 00:21:06.886 Now it pastes in 439 00:21:06.886 --> 00:21:09.250 Now press Enter 440 00:21:09.250 --> 00:21:12.233 You’ll see the directory has been changed 441 00:21:12.233 --> 00:21:15.900 We are going to run Hello World.exe from here 442 00:21:15.900 --> 00:21:17.930 Just type Hello World 443 00:21:17.930 --> 00:21:20.860 Instead of typing it all out, type the beginning 444 00:21:20.860 --> 00:21:22.638 Then press the tab key 445 00:21:22.638 --> 00:21:24.425 It will auto-complete 446 00:21:25.900 --> 00:21:27.304 If you press tab several times, 447 00:21:27.304 --> 00:21:30.949 The files with the same name 448 00:21:30.949 --> 00:21:34.664 in the folder will cycle through 449 00:21:34.664 --> 00:21:35.857 Select this one 450 00:21:37.778 --> 00:21:39.400 I will select this 451 00:21:39.400 --> 00:21:41.549 Use it and press Enter 452 00:21:41.549 --> 00:21:43.540 Hello World will be printed 453 00:21:43.540 --> 00:21:45.689 If you want 454 00:21:45.689 --> 00:21:47.302 to rewrite the previous code, 455 00:21:48.916 --> 00:21:50.603 just press the up arrow 456 00:21:50.603 --> 00:21:53.678 It will bring up the last thing you wrote 457 00:21:53.678 --> 00:21:55.969 Then leave a space 458 00:21:55.969 --> 00:21:58.638 Let’s try writing 1, 2, 3, 4 459 00:22:00.420 --> 00:22:02.070 Now press Enter 460 00:22:02.070 --> 00:22:05.980 This time, 1, 2, 3, 4 will be printed 461 00:22:05.980 --> 00:22:07.859 What this means is 462 00:22:07.859 --> 00:22:10.153 when you have an executable file like this, 463 00:22:10.153 --> 00:22:11.743 if you add a space 464 00:22:11.743 --> 00:22:13.993 after the executable file, 465 00:22:13.993 --> 00:22:18.799 it will be stored as a parameter 466 00:22:18.799 --> 00:22:20.404 So the parameter 467 00:22:20.404 --> 00:22:22.859 becomes available now 468 00:22:22.859 --> 00:22:24.805 Then we can 469 00:22:24.805 --> 00:22:28.009 print that value 470 00:22:30.979 --> 00:22:32.248 It’s simple, right? 471 00:22:32.248 --> 00:22:34.610 This is the structure 472 00:22:34.610 --> 00:22:37.636 In this way, 473 00:22:37.636 --> 00:22:40.082 we can create this program 474 00:22:40.082 --> 00:22:42.682 Again, there is the concept of Debug 475 00:22:42.682 --> 00:22:45.300 or Release 476 00:22:45.300 --> 00:22:48.850 Debug is for debugging 477 00:22:48.850 --> 00:22:53.479 It creates an executable file 478 00:22:53.479 --> 00:22:54.975 that helps find bugs 479 00:22:54.975 --> 00:22:58.383 Release is different 480 00:22:58.383 --> 00:23:01.579 it strips everything out for later release or packaging 481 00:23:01.579 --> 00:23:02.782 If you want to distribute it to others, 482 00:23:02.782 --> 00:23:05.266 usually, you set it to Release, 483 00:23:05.266 --> 00:23:06.055 then create it 484 00:23:06.055 --> 00:23:09.631 So, with both Release and Debug, 485 00:23:09.631 --> 00:23:13.213 you can create the same executable file 486 00:23:13.213 --> 00:23:15.359 To recap, this process 487 00:23:15.359 --> 00:23:16.798 is called the build process 488 00:23:17.434 --> 00:23:21.068 Basic Concepts of Programming and the C# Compiler Execution 489 00:23:21.269 --> 00:23:25.527 To clarify the term build, 490 00:23:33.998 --> 00:23:35.699 the build, like this 491 00:23:35.699 --> 00:23:38.461 The build process is this 492 00:23:38.461 --> 00:23:41.500 The source file, the C# code 493 00:23:41.500 --> 00:23:43.256 It's a code 494 00:23:43.256 --> 00:23:44.686 Let's say a code 495 00:23:46.289 --> 00:23:47.709 So this C# code 496 00:23:49.927 --> 00:23:51.070 It turns into an executable file 497 00:23:55.968 --> 00:23:58.109 The process of turning that code into a file 498 00:23:58.109 --> 00:24:00.754 is called build 499 00:24:00.754 --> 00:24:02.178 Then, when this code is 500 00:24:02.178 --> 00:24:04.962 made into an executable file, 501 00:24:04.962 --> 00:24:07.210 The action of making this happen 502 00:24:07.210 --> 00:24:08.398 is called compiling 503 00:24:11.339 --> 00:24:13.565 Yes, this is the structure 504 00:24:13.565 --> 00:24:17.397 I’ll explain this again later 505 00:24:17.397 --> 00:24:19.868 But roughly, this is how it looks 506 00:24:19.868 --> 00:24:21.991 The file that’s created 507 00:24:21.991 --> 00:24:24.699 will be here, as you see 508 00:24:24.699 --> 00:24:27.268 If you look, the Debug file is 509 00:24:27.268 --> 00:24:29.596 about 5KB 510 00:24:29.596 --> 00:24:31.579 Then, as for Release 511 00:24:31.579 --> 00:24:34.094 Ah, it’s the same, 5KB 512 00:24:34.094 --> 00:24:35.737 So, this is how it gets created 513 00:24:39.252 --> 00:24:42.579 Maybe because we haven’t written much, 514 00:24:42.579 --> 00:24:44.849 The size difference is almost nonexistent 515 00:24:44.849 --> 00:24:47.437 But as the code grows longer, 516 00:24:47.437 --> 00:24:49.688 the difference will become noticeable 517 00:24:54.749 --> 00:24:59.766 Also, I unknowingly wrote like this 518 00:24:59.766 --> 00:25:02.280 This is called a slash 519 00:25:02.280 --> 00:25:05.998 On the keyboard, right next to the right shift key, 520 00:25:05.998 --> 00:25:09.219 under the question mark 521 00:25:09.219 --> 00:25:10.690 That’s the one 522 00:25:10.690 --> 00:25:12.975 If you use it twice like this, 523 00:25:12.975 --> 00:25:15.536 this is called a comment in English 524 00:25:15.536 --> 00:25:16.488 A comment 525 00:25:19.780 --> 00:25:21.514 This is called a comment 526 00:25:21.514 --> 00:25:23.140 There are two types of comments 527 00:25:23.140 --> 00:25:28.078 One way is to comment out a single line 528 00:25:28.078 --> 00:25:31.622 So if you look here, if you do this, 529 00:25:33.849 --> 00:25:35.878 everything from here to the end 530 00:25:35.878 --> 00:25:37.888 becomes a comment, that’s the meaning 531 00:25:41.129 --> 00:25:44.528 And there’s another type of comment 532 00:25:44.528 --> 00:25:46.910 It looks like this 533 00:25:46.910 --> 00:25:49.680 Slash and asterisk 534 00:25:49.680 --> 00:25:51.547 Then an asterisk and a slash 535 00:25:51.547 --> 00:25:53.663 That's the other type 536 00:25:53.663 --> 00:25:55.669 This is a block comment 537 00:25:55.669 --> 00:25:58.556 It creates a specific block 538 00:25:58.556 --> 00:26:00.949 for commenting 539 00:26:00.949 --> 00:26:03.076 Like this 540 00:26:03.076 --> 00:26:04.816 Let's try using this 541 00:26:04.816 --> 00:26:06.904 For example, 542 00:26:06.904 --> 00:26:08.159 we can write it like this 543 00:26:08.159 --> 00:26:11.342 Then from here to here, it will be a comment 544 00:26:12.550 --> 00:26:13.338 It’s a bit different 545 00:26:13.338 --> 00:26:16.053 This one comments out the whole line 546 00:26:16.053 --> 00:26:18.567 While this one allows you to specify the start and end 547 00:26:18.567 --> 00:26:21.037 of a block comment 548 00:26:21.829 --> 00:26:23.076 So, in general, 549 00:26:23.076 --> 00:26:26.910 there are two types of comments 550 00:26:26.910 --> 00:26:28.489 If we talk about C language 551 00:26:28.489 --> 00:26:31.649 or C++, 552 00:26:31.649 --> 00:26:32.979 this is the old method 553 00:26:32.979 --> 00:26:35.471 A commenting method used, 554 00:26:35.471 --> 00:26:37.742 in C language 555 00:26:37.742 --> 00:26:40.606 This is the method used in C++, 556 00:26:40.606 --> 00:26:42.320 I can say that 557 00:26:42.320 --> 00:26:44.535 But since this is C#, 558 00:26:44.535 --> 00:26:45.949 instead of distinguishing like that, 559 00:26:45.949 --> 00:26:47.938 We can understand it 560 00:26:47.938 --> 00:26:50.937 as this one comments by creating a block 561 00:26:50.937 --> 00:26:53.532 And this one comments line by line 562 00:26:53.532 --> 00:26:56.006 That's how it works 563 00:26:59.031 --> 00:27:01.198 Now, let’s go back 564 00:27:01.198 --> 00:27:03.759 If you look here, there’s static 565 00:27:05.125 --> 00:27:07.337 Wait, if we look at the structure here, 566 00:27:07.337 --> 00:27:09.230 there’s also Internal 567 00:27:09.230 --> 00:27:11.314 These all have meanings 568 00:27:12.779 --> 00:27:14.877 I’ll explain these later 569 00:27:14.877 --> 00:27:18.262 when I talk about classes 570 00:27:18.262 --> 00:27:20.540 For now, I’ll talk a bit about this 571 00:27:20.540 --> 00:27:23.859 To explain this briefly, 572 00:27:23.859 --> 00:27:26.815 What we’re seeing here 573 00:27:26.815 --> 00:27:28.989 are what we call variables 574 00:27:28.989 --> 00:27:32.965 In this lecture, 575 00:27:32.965 --> 00:27:35.872 we’ll talk about variables next time 576 00:27:35.872 --> 00:27:38.903 But to put it simply, 577 00:27:38.903 --> 00:27:41.219 a variable is a container 578 00:27:41.219 --> 00:27:42.453 That holds a value 579 00:27:42.453 --> 00:27:44.532 that container is stored somewhere 580 00:27:44.532 --> 00:27:46.274 So this container 581 00:27:46.274 --> 00:27:48.430 is saved somewhere 582 00:27:48.430 --> 00:27:51.093 So, we need to understand 583 00:27:51.093 --> 00:27:53.460 this concept in terms of computer structure 584 00:27:54.847 --> 00:27:58.008 So, we’ll talk more about builds later 585 00:28:00.615 --> 00:28:02.369 Let’s take a look at computer structure 586 00:28:02.369 --> 00:28:04.452 This is how a computer looks 587 00:28:06.076 --> 00:28:08.848 If you open up a computer, you’ll see the motherboard 588 00:28:11.540 --> 00:28:13.304 And somewhere here 589 00:28:13.304 --> 00:28:17.357 is the central processing unit, the CPU 590 00:28:17.357 --> 00:28:19.979 Then memory goes here 591 00:28:19.979 --> 00:28:21.052 This is memory 592 00:28:22.982 --> 00:28:24.773 What we usually call RAM 593 00:28:24.773 --> 00:28:27.179 It’s called Random Access Memory, 594 00:28:27.179 --> 00:28:29.374 like Samsung RAM, Hynix RAM, 595 00:28:29.374 --> 00:28:30.660 and so many more 596 00:28:30.660 --> 00:28:32.261 RAM goes here 597 00:28:32.261 --> 00:28:35.488 And also, SSDs 598 00:28:35.488 --> 00:28:36.619 Things like that go in here 599 00:28:36.619 --> 00:28:40.070 The RAM is long and shaped like this 600 00:28:40.070 --> 00:28:45.203 So these are SSDs 601 00:28:45.203 --> 00:28:47.538 In the past, we used to call them HDD 602 00:28:47.538 --> 00:28:48.829 Hard Disk Drives 603 00:28:48.829 --> 00:28:51.595 That’s what we called them 604 00:28:51.595 --> 00:28:53.356 If you look at it broadly, 605 00:28:53.356 --> 00:28:55.509 this is called the Central Processing Unit 606 00:28:59.920 --> 00:29:02.804 The Central Processing Unit, CPU 607 00:29:02.804 --> 00:29:04.179 Then here’s the memory 608 00:29:04.179 --> 00:29:06.400 This is the main memory 609 00:29:10.819 --> 00:29:13.009 This is called secondary memory 610 00:29:17.437 --> 00:29:19.031 Actually, computers 611 00:29:19.031 --> 00:29:23.221 can be seen as having benchmarked 612 00:29:23.221 --> 00:29:25.380 human brains and concepts 613 00:29:25.380 --> 00:29:27.055 When a person has a brain 614 00:29:27.055 --> 00:29:30.434 The brain is here, right? 615 00:29:30.434 --> 00:29:32.589 What the brain mainly does 616 00:29:32.589 --> 00:29:35.659 is two things 617 00:29:35.659 --> 00:29:37.413 To handle calculations, 618 00:29:37.413 --> 00:29:40.247 and handle memory, right? 619 00:29:40.247 --> 00:29:42.096 So in a computer, 620 00:29:42.096 --> 00:29:45.890 there’s the CPU that handles calculations 621 00:29:45.890 --> 00:29:49.698 and the memory that handles storage 622 00:29:49.698 --> 00:29:51.803 Secondary memory like this 623 00:29:51.803 --> 00:29:54.938 isn’t really like the human body 624 00:29:54.938 --> 00:30:00.297 It’s more like a diary or your phone 625 00:30:00.297 --> 00:30:02.328 where you store things 626 00:30:02.328 --> 00:30:04.547 That way, the memory 627 00:30:04.547 --> 00:30:06.550 can be retrieved again 628 00:30:06.550 --> 00:30:09.239 So you can think of it that way 629 00:30:09.239 --> 00:30:13.569 When we need to handle information, 630 00:30:13.569 --> 00:30:15.626 we need to store it, right? 631 00:30:15.626 --> 00:30:17.088 So here, the parameter 632 00:30:18.909 --> 00:30:21.022 is like a container for storing 633 00:30:21.022 --> 00:30:23.016 Something in memory 634 00:30:23.016 --> 00:30:25.699 This memory is usually thought of 635 00:30:25.699 --> 00:30:27.103 So that container is ultimately 636 00:30:27.103 --> 00:30:29.372 stored in memory 637 00:30:29.372 --> 00:30:31.887 So that memory is usually thought of 638 00:30:31.887 --> 00:30:35.339 as main memory 639 00:30:35.339 --> 00:30:36.548 or secondary memory 640 00:30:36.548 --> 00:30:41.048 To be more precise, 641 00:30:41.048 --> 00:30:43.427 the part of memory 642 00:30:43.427 --> 00:30:45.579 that we use 643 00:30:45.579 --> 00:30:47.528 is the main memory 644 00:30:47.528 --> 00:30:50.121 The secondary memory 645 00:30:50.121 --> 00:30:51.987 is where our files 646 00:30:51.987 --> 00:30:53.400 are actually stored 647 00:30:53.400 --> 00:30:55.646 Of course, strictly speaking, 648 00:30:55.646 --> 00:30:58.504 there’s something called paging techniques 649 00:30:58.504 --> 00:31:01.754 where part of the secondary memory 650 00:31:01.754 --> 00:31:04.979 is used by the main memory 651 00:31:04.979 --> 00:31:07.883 But even without considering that, 652 00:31:07.883 --> 00:31:10.842 You can divide it like this 653 00:31:10.842 --> 00:31:12.966 So that’s the explanation 654 00:31:14.768 --> 00:31:18.085 So that's what it is 655 00:31:18.085 --> 00:31:19.759 This is how it looks like 656 00:31:19.759 --> 00:31:23.871 So, in the end, we’re storing values 657 00:31:23.871 --> 00:31:25.458 in memory 658 00:31:25.458 --> 00:31:28.315 This is what we wrote earlier 659 00:31:28.315 --> 00:31:30.332 when you write it like this, 660 00:31:30.332 --> 00:31:32.094 It gets stored somewhere 661 00:31:32.094 --> 00:31:34.342 and then it comes over here, right? 662 00:31:34.342 --> 00:31:36.707 It’s passed over, and that’s the concept 663 00:31:36.707 --> 00:31:38.339 that we use 664 00:31:38.339 --> 00:31:40.746 So that container is ultimately 665 00:31:42.979 --> 00:31:45.108 stored in memory 666 00:31:45.108 --> 00:31:47.582 Is memory a single space? 667 00:31:47.582 --> 00:31:48.939 No, it’s not 668 00:31:48.939 --> 00:31:51.553 Memory is divided into parts 669 00:31:51.553 --> 00:31:54.155 To put it simply, 670 00:31:54.155 --> 00:31:57.060 it’s divided into four main sections 671 00:31:57.060 --> 00:32:00.663 So it’s split into four areas 672 00:32:00.663 --> 00:32:03.763 There’s the code area 673 00:32:03.763 --> 00:32:06.859 Then the data area 674 00:32:06.859 --> 00:32:10.156 Next is the heap and the stack 675 00:32:10.156 --> 00:32:13.127 These are the areas 676 00:32:13.127 --> 00:32:14.835 But code is usually 677 00:32:14.835 --> 00:32:16.911 what we’ve written in our program 678 00:32:16.911 --> 00:32:20.605 That’s what’s stored as assembly language 679 00:32:20.605 --> 00:32:24.447 The actual code becomes machine language 680 00:32:24.447 --> 00:32:26.992 You can call it machine language 681 00:32:26.992 --> 00:32:28.604 Those machine instructions 682 00:32:28.604 --> 00:32:30.619 are stored in memory 683 00:32:30.619 --> 00:32:33.220 That’s the code area 684 00:32:33.220 --> 00:32:36.070 Then the data area contains static variables 685 00:32:38.900 --> 00:32:41.409 In C#, it’s where static variables 686 00:32:43.699 --> 00:32:45.508 and global variables exist 687 00:32:45.508 --> 00:32:46.764 That's what it is 688 00:32:46.764 --> 00:32:50.459 The heap is the space we create when needed 689 00:32:50.459 --> 00:32:53.279 and remove when it’s no longer necessary 690 00:32:53.279 --> 00:32:55.469 It’s where memory is dynamically allocated 691 00:32:55.469 --> 00:32:59.707 So usually when you create memory 692 00:32:59.707 --> 00:33:02.608 with the New keyword 693 00:33:02.608 --> 00:33:04.108 That memory 694 00:33:04.108 --> 00:33:05.619 is called the heap 695 00:33:05.619 --> 00:33:10.298 The stack is for function parameters 696 00:33:12.900 --> 00:33:15.498 or local variables 697 00:33:17.957 --> 00:33:21.696 Since this is your first time, it’s fine if you don’t understand everything 698 00:33:21.696 --> 00:33:24.178 But it’s good to have an idea 699 00:33:24.178 --> 00:33:27.140 that memory is divided this way 700 00:33:27.140 --> 00:33:28.550 That's what it is 701 00:33:28.550 --> 00:33:31.349 The key feature of these 702 00:33:31.349 --> 00:33:34.187 is a concept called the Lifecycle 703 00:33:41.048 --> 00:33:42.216 It's called Lifecycle 704 00:33:42.216 --> 00:33:47.009 Simply put, the application app runs, 705 00:33:47.009 --> 00:33:49.481 and then it ends, right? 706 00:33:51.431 --> 00:33:53.981 During this time, 707 00:33:53.981 --> 00:33:56.687 the variables use memory 708 00:33:56.687 --> 00:33:59.476 when they’re created, 709 00:33:59.476 --> 00:34:02.409 and when they disappear 710 00:34:02.409 --> 00:34:03.979 That's the gist of the lifecycle 711 00:34:03.979 --> 00:34:06.002 So, the code will naturally 712 00:34:06.002 --> 00:34:08.382 continue to exist 713 00:34:08.382 --> 00:34:10.393 until the application terminates 714 00:34:10.393 --> 00:34:12.709 The same applies to the data section 715 00:34:12.709 --> 00:34:14.911 Both of these exist while the app is running 716 00:34:16.812 --> 00:34:19.600 and disappear when it terminates 717 00:34:19.600 --> 00:34:23.643 The heap, however, can be created and destroyed by the user 718 00:34:23.643 --> 00:34:26.587 The stack is allocated when a function is called 719 00:34:26.587 --> 00:34:28.408 This process is known as a function call, 720 00:34:28.408 --> 00:34:30.370 when the function call is made, memory is allocated, 721 00:34:30.370 --> 00:34:33.364 and when the function terminates, the memory is freed 722 00:34:33.364 --> 00:34:36.521 For now, you don’t need to fully understand these concepts, 723 00:34:36.521 --> 00:34:39.189 but the key point I want to emphasize here 724 00:34:39.189 --> 00:34:41.673 is the term static, 725 00:34:41.673 --> 00:34:43.288 spelled as static 726 00:34:45.340 --> 00:34:47.788 It is something 727 00:34:47.788 --> 00:34:52.028 that exists from the very beginning 728 00:34:52.028 --> 00:34:54.355 It is created at the start 729 00:34:54.355 --> 00:34:56.047 and remains throughout execution 730 00:34:56.047 --> 00:34:58.159 In other words, static elements always exist 731 00:35:00.260 --> 00:35:02.719 Since they disappear only when the app terminates, 732 00:35:02.719 --> 00:35:04.989 they effectively persist 733 00:35:04.989 --> 00:35:07.100 for the entire runtime of the application 734 00:35:07.100 --> 00:35:09.250 That’s why the static keyword 735 00:35:09.250 --> 00:35:10.349 is used here 736 00:35:10.349 --> 00:35:12.601 So see here 737 00:35:12.601 --> 00:35:15.260 We have static and Main functions 738 00:35:15.260 --> 00:35:17.273 This Main function exists 739 00:35:17.273 --> 00:35:18.752 from the very beginning, 740 00:35:18.752 --> 00:35:20.315 right from the start 741 00:35:21.939 --> 00:35:24.569 That’s why the static keyword is used here 742 00:35:24.569 --> 00:35:26.671 All static elements 743 00:35:26.671 --> 00:35:30.238 are created at the same time, 744 00:35:30.238 --> 00:35:31.298 so they exist together throughout execution 745 00:35:31.298 --> 00:35:32.684 Like this 746 00:35:32.684 --> 00:35:34.539 Now, let’s wrap up 747 00:35:34.539 --> 00:35:37.379 the explanation of Main 748 00:35:37.379 --> 00:35:38.907 The Main function 749 00:35:46.820 --> 00:35:48.693 is referred to as such 750 00:35:50.149 --> 00:35:55.348 It's an C# application 751 00:35:57.580 --> 00:35:59.047 Application, 752 00:36:00.979 --> 00:36:03.332 or app for short 753 00:36:03.332 --> 00:36:06.458 It is the entry point of a C# application 754 00:36:09.540 --> 00:36:11.455 That means it is the very first function 755 00:36:12.643 --> 00:36:15.968 when what starts? 756 00:36:15.968 --> 00:36:18.834 When the app starts 757 00:36:18.834 --> 00:36:21.478 It gets called 758 00:36:23.860 --> 00:36:25.751 when the application starts 759 00:36:25.751 --> 00:36:26.514 That's what it is 760 00:36:26.514 --> 00:36:29.619 This is why Main is known as the entry point 761 00:36:29.619 --> 00:36:31.820 In C#, there is only one entry point, 762 00:36:31.820 --> 00:36:34.610 which means 763 00:36:34.610 --> 00:36:37.409 a program can have 764 00:36:39.659 --> 00:36:40.565 only one Main function 765 00:36:40.565 --> 00:36:42.783 So there's only one Main function 766 00:36:44.694 --> 00:36:45.590 That's what it is 767 00:36:53.780 --> 00:36:55.710 If we visualize this with a diagram, 768 00:36:55.710 --> 00:36:57.124 it would look something like this 769 00:36:58.283 --> 00:37:00.210 There is an operating system, 770 00:37:00.210 --> 00:37:02.712 commonly abbreviated as OS 771 00:37:02.712 --> 00:37:03.914 Operating system 772 00:37:03.914 --> 00:37:05.828 Some examples of OS 773 00:37:09.377 --> 00:37:12.188 include things like 774 00:37:12.188 --> 00:37:12.981 Windows, 775 00:37:16.654 --> 00:37:18.102 which we use a lot, 776 00:37:18.102 --> 00:37:21.286 Mac or Macintosh, 777 00:37:21.286 --> 00:37:23.199 Macintosh 778 00:37:23.199 --> 00:37:27.372 Linux, and Unix 779 00:37:28.461 --> 00:37:30.373 For mobile devices, we have 780 00:37:31.928 --> 00:37:34.899 operating systems like Android 781 00:37:34.899 --> 00:37:37.749 The operating system 782 00:37:37.749 --> 00:37:41.297 runs applications, 783 00:37:41.297 --> 00:37:43.054 which execute within its environment 784 00:37:44.500 --> 00:37:47.134 So, in the OS, 785 00:37:47.134 --> 00:37:50.180 an application runs as a process 786 00:37:50.180 --> 00:37:53.073 When it starts, the very first function that gets called 787 00:37:53.073 --> 00:37:55.045 is the Main function 788 00:37:56.540 --> 00:37:57.603 That's the structure 789 00:37:58.762 --> 00:38:00.953 Applications, in another term, 790 00:38:00.953 --> 00:38:03.528 are also called processes 791 00:38:05.719 --> 00:38:06.917 To explain this further, 792 00:38:06.917 --> 00:38:08.863 it can be a little tricky 793 00:38:08.863 --> 00:38:11.748 If you right-click on your desktop 794 00:38:11.748 --> 00:38:13.750 and open the Task Manager, 795 00:38:13.750 --> 00:38:14.625 here, 796 00:38:15.912 --> 00:38:16.983 you will see a section 797 00:38:16.983 --> 00:38:19.435 labeled Processes 798 00:38:19.435 --> 00:38:22.419 All the running applications are listed here, 799 00:38:22.419 --> 00:38:25.022 including both active applications 800 00:38:25.022 --> 00:38:26.692 and background processes 801 00:38:26.692 --> 00:38:28.235 This means an application 802 00:38:28.235 --> 00:38:30.557 is just one type of process 803 00:38:34.181 --> 00:38:37.979 Hopefully, this gives you a general understanding 804 00:38:37.979 --> 00:38:41.057 This isn’t a difficult concept 805 00:38:41.057 --> 00:38:42.436 Once you grasp the structure, 806 00:38:42.436 --> 00:38:44.304 everything becomes clearer 807 00:38:44.304 --> 00:38:45.699 So that's what it is 808 00:38:45.699 --> 00:38:48.672 Let's summarize this 809 00:38:48.672 --> 00:38:52.149 And there’s one more thing I want to mention 810 00:38:52.149 --> 00:38:56.308 The question here is, 811 00:38:56.308 --> 00:39:00.567 how does C# actually run? 812 00:39:02.300 --> 00:39:05.631 Earlier, I talked 813 00:39:05.631 --> 00:39:07.259 about the build process, 814 00:39:10.139 --> 00:39:15.191 When we talk about builds, 815 00:39:15.191 --> 00:39:17.069 it applies not only to C# 816 00:39:17.069 --> 00:39:20.798 but also to languages like Python, 817 00:39:20.798 --> 00:39:22.966 Java, and more, 818 00:39:22.966 --> 00:39:25.133 like C, and C++ 819 00:39:25.133 --> 00:39:27.006 Same thing here 820 00:39:27.006 --> 00:39:28.826 In the build process, 821 00:39:28.826 --> 00:39:32.302 we write code using a structured, 822 00:39:32.302 --> 00:39:36.820 human-readable programming language 823 00:39:36.820 --> 00:39:39.543 For example, in C#, it's a C# code 824 00:39:39.543 --> 00:39:41.256 So this is essentially a file 825 00:39:42.860 --> 00:39:46.665 we write code in .cs files 826 00:39:46.665 --> 00:39:48.818 That's the extension 827 00:39:48.818 --> 00:39:51.692 This code then 828 00:39:51.692 --> 00:39:53.590 needs to be compiled 829 00:39:57.070 --> 00:40:00.192 When we compile it, 830 00:40:00.192 --> 00:40:01.840 it first gets translated 831 00:40:06.506 --> 00:40:08.620 The build process may differ 832 00:40:08.620 --> 00:40:10.342 with different languages 833 00:40:11.936 --> 00:40:13.955 Let me start with this first 834 00:40:13.955 --> 00:40:15.775 For C#, 835 00:40:15.775 --> 00:40:19.309 it gets translated into an intermediate language 836 00:40:19.309 --> 00:40:21.478 this intermediate language is packaged 837 00:40:21.478 --> 00:40:26.117 into either an exe or dll 838 00:40:27.820 --> 00:40:29.881 like .exe 839 00:40:29.881 --> 00:40:31.561 Exe refers 840 00:40:31.561 --> 00:40:33.031 to executable file 841 00:40:33.031 --> 00:40:34.750 Dll means 842 00:40:34.750 --> 00:40:37.120 dynamic link library 843 00:40:37.120 --> 00:40:39.404 So it's a dynamic link library 844 00:40:40.760 --> 00:40:42.768 That's the file extension we get 845 00:40:42.768 --> 00:40:44.587 Metadata is also generated alongside these files, 846 00:40:48.013 --> 00:40:50.641 so we have these here 847 00:40:50.641 --> 00:40:52.445 So we have these files 848 00:40:52.445 --> 00:40:56.547 Now, to actually execute these files, 849 00:40:56.547 --> 00:40:59.357 the operating system needs to interpret and run them 850 00:41:00.634 --> 00:41:03.369 Now, when the necessary information 851 00:41:03.369 --> 00:41:06.081 moves through this process, 852 00:41:06.081 --> 00:41:07.387 something happens here 853 00:41:09.815 --> 00:41:12.229 There’s something called the Common Language Runtime 854 00:41:12.229 --> 00:41:14.127 or CLR 855 00:41:14.127 --> 00:41:17.688 It's called Common Language Runtime 856 00:41:17.688 --> 00:41:19.783 During compilation, the intermediate language 857 00:41:19.783 --> 00:41:23.075 is usually called CIL, 858 00:41:23.075 --> 00:41:28.354 or Common Intermediate Language 859 00:41:28.354 --> 00:41:30.704 That's CIL 860 00:41:30.704 --> 00:41:34.330 So, CIL is generated as an intermediate language 861 00:41:34.330 --> 00:41:37.199 In Java, this would be referred to as bytecode 862 00:41:37.199 --> 00:41:40.781 It's called a bytecode 863 00:41:42.969 --> 00:41:45.565 But calling it an intermediate language 864 00:41:45.565 --> 00:41:47.822 is more accurate in this case 865 00:41:47.822 --> 00:41:49.499 Anyway, this intermediate language 866 00:41:49.499 --> 00:41:51.500 is created like so, 867 00:41:51.500 --> 00:41:54.443 and then something called CLR processes it 868 00:41:54.443 --> 00:41:58.088 CLR converts it into native code 869 00:42:02.899 --> 00:42:04.709 That’s what happens 870 00:42:04.709 --> 00:42:06.838 In Java, this process is handled 871 00:42:06.838 --> 00:42:08.658 by something called VM or Virtual Machine 872 00:42:08.658 --> 00:42:11.561 C# has a very similar structure to Java 873 00:42:11.561 --> 00:42:14.538 This is why we call it the .NET environment 874 00:42:16.927 --> 00:42:18.560 It’s commonly known as the .NET Framework 875 00:42:18.560 --> 00:42:21.540 A .Net environment 876 00:42:21.540 --> 00:42:23.812 When we build C# code, 877 00:42:23.812 --> 00:42:26.840 it produces an intermediate language file 878 00:42:26.840 --> 00:42:28.106 This file is then 879 00:42:28.106 --> 00:42:31.158 processed inside the operating system 880 00:42:31.158 --> 00:42:34.758 by a virtual machine, or the CLR, 881 00:42:34.758 --> 00:42:36.852 which converts it into native code 882 00:42:36.852 --> 00:42:39.186 That native code is what the operating system 883 00:42:39.186 --> 00:42:40.266 actually executes 884 00:42:41.820 --> 00:42:44.871 That’s the structure of the process 885 00:42:44.871 --> 00:42:46.650 So, all we need to do is write the code 886 00:42:46.650 --> 00:42:48.024 Then, with this, 887 00:42:48.024 --> 00:42:49.926 when we compile it, 888 00:42:49.926 --> 00:42:52.189 an intermediate language file like .exe or .dll is created 889 00:42:52.189 --> 00:42:55.765 With that file, the program can be run 890 00:42:55.765 --> 00:42:57.848 on various operating systems 891 00:42:57.848 --> 00:42:59.633 So that's the Virtual Machine 892 00:42:59.633 --> 00:43:01.162 That’s why it’s all 893 00:43:01.162 --> 00:43:02.965 called a virtual machine 894 00:43:05.500 --> 00:43:07.522 Through this virtual machine, 895 00:43:07.522 --> 00:43:10.287 different operating systems 896 00:43:10.287 --> 00:43:12.266 are able to run the program 897 00:43:12.266 --> 00:43:14.373 The system is pre-configured 898 00:43:14.373 --> 00:43:15.989 so that it can execute properly regardless of the OS 899 00:43:15.989 --> 00:43:19.081 That’s how execution works 900 00:43:19.081 --> 00:43:22.699 This is the build process of C# 901 00:43:22.699 --> 00:43:25.846 From building to execution, 902 00:43:25.846 --> 00:43:27.710 this is the full process 903 00:43:27.710 --> 00:43:30.103 In C, the process is different 904 00:43:30.103 --> 00:43:31.280 It's not like this 905 00:43:31.280 --> 00:43:34.769 C first goes through preprocessing, 906 00:43:34.769 --> 00:43:38.416 then compilation 907 00:43:40.129 --> 00:43:42.233 After that, it generates object files 908 00:43:42.233 --> 00:43:45.624 Then, the linker takes these object files and links them together, 909 00:43:45.624 --> 00:43:49.139 combining them into a final .exe file 910 00:43:49.139 --> 00:43:50.180 That's how it works 911 00:43:50.180 --> 00:43:55.176 For this, the compiled and linked executable is different 912 00:43:55.176 --> 00:43:59.379 Each OS generates a different type of executable 913 00:43:59.379 --> 00:44:02.862 so C programs aren’t inherently cross-compatible 914 00:44:02.862 --> 00:44:05.208 C# was designed to be more universal, 915 00:44:05.208 --> 00:44:06.849 unlike other languages 916 00:44:06.849 --> 00:44:10.428 So it first compiles into an intermediate language 917 00:44:10.428 --> 00:44:14.711 Then, this intermediate code is processed 918 00:44:14.711 --> 00:44:17.699 by a Common Language Runtime or CLR, 919 00:44:17.699 --> 00:44:20.476 which acts as a virtual machine to convert it 920 00:44:20.476 --> 00:44:22.784 into native code for the specific OS 921 00:44:22.784 --> 00:44:24.699 That's how it works 922 00:44:24.699 --> 00:44:28.134 Let's summarize what we've learned today 923 00:44:28.595 --> 00:44:30.322 Summary Installing Visual Studio & Running Hello World Install Visual Studio through Visual Studio Installer 924 00:44:30.322 --> 00:44:32.042 The installer expands Visual Studio’s functionality Create a new project → Select C# under All Languages (L) Select Console under All Project T 925 00:44:32.042 --> 00:44:33.813 Enter Project Name and Solution Name, then click Create WriteLine Hello World 926 00:44:33.813 --> 00:44:35.506 Debug: Creates an executable for debugging Release: Creates an executable for distribution 927 00:44:35.506 --> 00:44:37.926 Programming Basics and C# Compiler Execution Process Build: The process where C# code becomes an executable Main Function: The first function call 928 00:44:37.926 --> 00:44:40.221 Compilation: The step before code turns into an executable Variables: Store values in memory Memory Sections Code: Machine code stored in memory 929 00:44:40.221 --> 00:44:42.525 Data: Stores static variables Heap: Allocates and deallocates memory as needed Stack: Stores function parameters and local variables 930 00:44:42.535 --> 00:44:45.485 C# Compiler Execution Process Write C# Code Compile C# files, generating .exe or .dll intermediate language 931 00:44:45.485 --> 00:44:48.446 CLR (Common Language Runtime) in .NET converts this into native code Native code runs on the OS