Let's take a look at how to install Visual Studio using the custom option. For this example, we'll use the Community Edition of Visual Studio 2015. In order to get it, simply visit visualstudio.com and click on the Download Community 2015 button. Once we've clicked on the download, it'll download to our computer and it's a web installer. So we click on the Run button and it will initiate the installation routine for Visual Studio Community 2015. Once we have the option screen available, it's time to start looking at customizing the installation of Visual Studio. For the most part, the default allows you to create web and desktop type applications. But if you want to create different styles of applications or include more languages, then the custom option is what you should be choosing. I always recommend selecting the custom option for the installation of Visual Studio 2015 to ensure that you're getting the packages and libraries that you need to create the applications you may wish to use. So by selecting Custom and clicking on the Next button, we are now brought to the screen where we can select the different features. The first option is Programming Languages. And if we click the arrow to expand it, we can see that we have Visual C++, Visual F-sharp, and the Python tools for Visual Studio that are additional programming languages that will get installed if you select this option. Remember, by default, Visual Studio Community Edition will only install C-sharp in Visual Basic Templates. Also notice under Visual C++, we have options for the common tools, the Microsoft Foundation classes, and then Windows XP support for C++. For my purposes, I like to have all of my programming languages available to me because I create projects using the different languages all the time. So I'm going to select the checkbox next to Programming Languages to install all of those programming types. Also, under Windows and Web Development, we can choose various options here for things such as Quick Ones Publishing tools, SQL Server Data tools, PowerShell tools for Visual Studio, Silverlight Development, etc. Here's a very important component. If you want to develop universal Windows applications, we need to ensure that we have the tools, the emulators, and the SDK. Now, you can choose the default install of Visual Studio, and then come back and install the Windows 10 SDK at a later time, and that will include the tools, the SDKs, and the emulators for you. But it's so much easier to install these during the installation of Visual Studio. Please note that it will increase the install size of the application, so the tool set will be much larger. So again, depending on what it is that you want to do, you may want to select Universal Windows App Development Toolkit, PowerShell tool for Windows, or for Visual Studio, rather, if you want to be using PowerShell tools within your applications. If you need backward compatibility for Windows 8.1 and Windows Phone 8.0 and 8.1, you can select this option. Also, there are some common tools or cross-platform mobile development tools. These are important if you want to develop applications using the Xamarin platform. Xamarin is a cross-platform tool that allows you to create applications for Windows Phone, for iOS devices, and for Android devices by using the C-Sharp Language in Visual Studio. All of these tools are available for the cross-platform mobile development using Xamarin platform. It includes all of the emulators as well. So again, remember, it will increase the size of the install base for Visual Studio. You might also notice that because I selected the cross-platform mobile development tools, we now have a little box inside the Windows 8.1 and Windows Phone tools. If we expand that, we'll see that it has included tools and Windows SDKs. And the reason it does that is because there's a potential that you may want to target Windows Phone 8.0 or 8.1 applications. So the tools and SDKs will also get installed. At the same time, the common tools check box includes a little square box indicating that we have also added another component here, and that is the git for Windows. So we can install git, which is your source control, git hub extension to Visual Studio so that you can integrate with git hub source control projects, and then of course, an extensibility tool to update three for Visual Studio as well. You'll notice that by selecting all of these options, setup can require up to 48 gigabytes across all of the drives that we'll install it on. So again, review each of the items that you have selected to ensure you have all the necessary components, tools, and SDKs. For your development, tools of choice or platforms of choice, and then select the next button. Once you do, you basically see a quick little selected features screen that will tell you all of the different items that you have selected. And by clicking install, you'll agree to the license terms of all the software components. If you're not sure what those are, each one of the items that has license terms allows you to click on it to view those. Once you're satisfied with it, click the install button and Visual Studio starts installing all of the components that you have selected. So this is a quick overview of how to perform a custom installation of Visual Studio 2015. Hi, I'm Bob Taber with Developer University. For more of my training videos for beginners, please visit me at devview.com. In this lesson, I want to build a super simple C sharp application I want you to follow along. It's a Hello World application, meaning that we're merely going to print out the words Hello World to a console window. And the point of this exercise is just to show you the basic workflow. So I'm not going to attempt to even explain why we're doing what we're doing. The focus will be on what I'm going to do next and how I'm doing it. In other words, I want you to focus on the basic workflow. That'll be the same for all the applications we'll build in this course and pretty much every application you'll ever build using C sharp. Things like how to create a new project. Where do you type in your C sharp code? How do you test your application to make sure that it's running correctly and what do you do whenever you have an error in your code? How do you save your project? Things of that nature. So for now, just try to follow along. Don't worry if something doesn't make a lot of sense at this point. That's really what the rest of this course is for. The next few lessons after this one, we're going to dissect this tiny little application that we built. And I'm going to explain at that point why we did what we did and then what does the code mean and why it's doing what it's doing. And just a quick reminder, like I said in the previous video, the introduction of this course, I'm going to assume that you have some version and some addition to Visual Studio already installed. Even if your Visual Studio looks a little bit different than mine does on camera here, don't be overly concerned about that. The basics are the same no matter what, I promise. All right, so let's go ahead and get started here. And to begin, we're going to create a new project. There are a number of different ways to do this, but I'm going to keep it simple and go to File, New, Project. And selecting that menu option will open up the new project dialog. Now, chances are the number of items that you see here in this center part will be dramatically different than the items that I see based on which version and addition of Visual Studio that you have installed. However, you should be able to select templates and then select C sharp. And one of the options should be a console application. So I want you to select that and then we're going to rename this project to Hello World. Now, notice, I used a little naming convention where I use a capital H and Hello and a capital W in World, and I don't use a space in between the two words. Now, that's just a naming convention that I came up with to help me identify projects a little bit easier, something I recommend that you follow. We shouldn't have to make any other changes in this dialog. I'm going to go ahead and click the OK button. And Visual Studio will go off and now create the starting point of a console window application for us. All right. And so now you should see in this main area, in this text area, a file open called program.cs. And there's some code here that is already generated for us, boilerplate code. We're going to ignore most of that, except we're going to find this innermost set of curly braces. Now, one of the first things you're going to need to do when you're learning how to develop software is tell the difference between parentheses, curly braces, square brackets, angle brackets, and I don't know that I left out any, OK?  These are important. I want to go inside of those two, that opening and closing curly brace and make some room for ourselves. This is where we're going to type our code. So it's approximately line 13 and 14, at least in my copy of Visual Studio. And then I'm going to type in the following. Type in console and you may notice now this little window pops up below what I'm typing. You can safely ignore that for now. Eventually, this becomes our best friend. But for now, it might kind of be distracting and give the way to try to ignore it and type in everything by hand to the best of your ability. Console and then I want to use the period on the keyboard.  So console dot and then capital W write capital L line. Next, I'm going to use an opening and closing parentheses. So that's not a curly brace. These are just the characters you would use for a smiley face in an emoticon. And then inside of there, I'm going to use the arrow keys on my keyboard to kind of navigate around here. I'm going to go inside of the opening and closing parentheses. And I'm going to use two double quotes. So it should look like that. All right, make sure you don't use single quotation marks like that. That's not what we want. We want double quotation marks like that. Okay. And inside of there, we're going to type in the words hello in world. All right. So make sure that you have an open parentheses, a double quote, the words hello world, then another double quote, then another parentheses, a closing parentheses. And then at the very end of this line, I'm going to use a semicolon and it looks like that. All right. And it's not a colon. And it's not a comma. All right. It looks like that. All right. And then I'm going to use the inner key on my keyboard to go to the next line. I'm going to type in console dot capital read capital L in line, opening and closing parentheses. Now you may have noticed that as you, as you type in the opening parentheses, that visual studio will automatically type in a closing word for you. Don't let that throw you can continue just to type through. That but make sure that you have exactly what I've typed into my code window here for these two lines of code. Make sure that the capitalization is correct. Make sure that you're using a period not a comma for for the for the little mark that comes after the word console. Make sure you're using parentheses and not some other type of bracket or brace and then make sure that both lines of code end with a semicolon. All right. So the next thing that I want to do is save my project. So I'm going to go and there are a number of different ways to do this in visual studio. Again, I keep it simple and go to file, save all. All right. And then the next thing I want to do is now see my application actually running. And so to do that, I can either find this little green arrow, this little green triangle that has the word start next to it. Or if I don't see that by default in my little toolbar here at the top, I can go to debug and select start debugging. Either way should work. I'm going to go ahead and click that. And you'll notice that some windows pop up and visual studio changes its appearance a little bit. Now off to the side of my screen, the console window popped up and we see the words hello world with a blinking cursor below it. I'm just going to hit the enter key on my keyboard and then the console window disappears and I'm back individual studio kind of resets itself and we're successful, right? However, maybe your experience wasn't successful. Maybe you saw an error message. So what I want to do is take a moment and look at some common errors that people that are new to C sharp might run into and how to remedy them. And this is a good opportunity to learn some of the syntax rules of C sharp as we make mistakes. Okay, so I'm going to pause the video, make a mistake and then we'll talk about it, pause it and so on. Alright, so when you attempted to start the application, you may have seen a little dialogue pop up from visual studio that says there were build errors. Would you like to continue and run the last successful build? Always select no for that. Okay, and what you'll see next is a list of errors. Now, in some cases, the error messages will be obvious to you and they'll make a lot of sense. Sometimes they won't like the the verbiage might be something for just not familiar with yet invalid token and class structure interface. What does that mean? Okay, so typically what you can just do is double click on these and it'll put your mouse cursor on the line where the problem is. Notice that visual studio also gives you another visual way to tell that there's a problem with your code gives you this little red squiggly line. Sometimes you'll see blue squiggly line. They're a little bit different, but essentially this is an area of the code that probably deserves your attention. Something you need to fix. Now, in this particular case, the problem is that we didn't type our code in between the innermost opening and closing curly braces. And so this is an issue with regards to defining a code block in C sharp or a block of code. So different C sharp commands belong in different kinds of code blocks. And I'm going to spend a lot of time in this course talking about the different types of code blocks and what belongs in each type of code block. But to remedy this issue, what you need to do is use your your mouse and just kind of drag and highlight these two lines. Or you can use the shift key on your keyboard and the arrow keys to kind of highlight that area. Hit control X, then move up in between the opening and closing curly brace and paste control V that code in there. And then it should run correctly at that point. All right. So that teaches us the first thing about C sharp. It matters where we type our code. All right. Or when you try to run the application, you may have seen the same build error dialogue. Except you see the message semi colon expected. Hopefully this is an obvious remedy for you. If you double click on that error in the error list, it should take you to the end of the line of code where you forgot to add a semi colon. And so that's the second thing about C sharp that we're going to learn is that just like a properly formed English sentence has to end with a period or a question mark or an exclamation mark. A properly formed instruction in C sharp has to end with a semi colon. All right. Or maybe the error that you saw was something like a syntax error, something expected. The name hello doesn't exist in the current context. The name world doesn't exist in the current context. If you were to double click these, you'll get to the vicinity of the problem. And you'll also see that there's red squiggly lines beneath the words hello and world in between of our parentheses. Now remember, we needed to use double quotation marks around that string of characters hello world. And so alphanumeric characters that we want to literally write to screen or present in some way. We need to surround them with characters that indicate that we want to use this literal string, the string of literal characters. Okay. So to do that, we use double quotes, or perhaps you see the error, something like the name console does not exist in the current context. You're like, doesn't exist in the current context. You look at the word and you say, well, looks spelled correctly. Remember that I told you you had to type exactly what I was typing. And so C sharp is case sensitive, meaning that a lower case C and an uppercase C mean that you're typing two completely different things into C sharp. Okay. And that that does that is tricky because many of us are not used to that degree of precision whenever we're communicating. But when communicating with a computer, you have to be precise. So in this case, all we needed to do was change the capitalization of the word console. And we're back in business. Or perhaps you see something like console does not contain a definition for either right line or read line. And again, you're looking at it and you're thinking it's spelled correctly. Well, what could the problem be? Here again, capitalization is important. Lower case R read line is different than uppercase R read line. And lower case L read line is different than lower case uppercase L read line. Okay. And so again, things have to be spelled spelled correctly and have the correct capitalization in order to be processed correctly by the C sharp compiler. We'll talk about compilation in the next lesson. Now, fortunately, if you're not good at spelling and you're not good at typing and capitalization and you're just not as precise in the way that you would type a letter or an email message or even a text message. Fortunately, Visual Studio can help you out. There are tools that will help you not only write your code more quickly but also more accurately. And chances are if you utilize those tools, the chances that you will miss some of these really simple syntax things like capitalization will almost be completely eliminated. We'll talk about some of those tools in an upcoming lesson. All right. But assuming that you got all of this to work correctly, you're really well on your way to building applications. You've already crossed over one of the big first steps. And as you undoubtedly learned in this lesson, writing C sharp code is an exercise in being precise in precision. And again, fortunately, the Visual Studio IDE will help you out a lot when it comes to that. It will give you clues and maybe some of the phrases and the words that they use to explain the issue might not be familiar to you yet with experience. It will be. But generally, it'll point you into the right direction and with the red squiggly lines in the message, you can typically figure out what the issue is. Now throughout this course, if you run into a wall and you simply can't figure out what the problem is, do this. Compare character by character. Take your time until you kind of develop a vision for the problems where your eye will jump to the problem and code. Compare what you wrote versus what I wrote. I'll supply the source code to you. And so open it up in a second copy of Visual Studio and then just look line character by character. What did I do different than what Bob did? All right. And that will usually help you figure things out if you can't do it on your own. All right. So in the following lessons, we're going to focus on two things. First of all, we're going to talk about why we did what we did and what was going on behind the scenes that turned our code. Turned our code into a working application, albeit a small application. What happens whenever we create a new project? What happens whenever we choose to save our project? What happens whenever we choose to start or run our application? And then secondly, we're going to talk about the syntax of the C sharp code that we wrote. And we'll learn more syntax rules and more keywords as we go along. So if precision is so very important in C sharp, then you're going to need to have some explanation as to what all those little words and symbols actually mean and some rules to guide you as you're writing your own code. It's really easy once you get a few of the basics under your belt. Being completely honest, many, many people learn how to code, how to write code and C sharp is a fairly easy language to learn. You can do this. Just you got to put a little bit of time, a little bit of effort to figure it out. All right, so we'll begin that process in the very next lesson. We'll see you there. Thanks. Hi, I'm Bob Tabor with Developer University. For more of my training videos for beginners, please visit me at devu.com. Now in this lesson, we want to start the process of dissecting that little application that we wrote in the previous lesson. Now previously, I wanted you to focus on the workflow, what we did and how we did it. But now what I want to do is focus on why we did what we did. It's really crucial at this point that we cement some really important ideas in your mind because they're going to provide the basis, the foundation for everything that comes next. So what I want to do is start on the inside and kind of work our way out. And I'll start by talking about the nature of writing code. When you learn how to write applications with C sharp, really any programming language, learning the syntax of C sharp, or in other words, learning the nouns and the verbs and the punctuation of the programming language is really just half the battle. The other half of the battle is learning about related prebuilt functionality that's available to the code that you write. Now in our case, Microsoft has created something called the dot net framework, which sounds kind of spooky and mysterious, but it's really not that bad. It's actually pretty large, but we're only going to focus on two specific portions of it for our purposes. The first part that I want to focus on is something called the class library, which is simply just a library of code that Microsoft wrote to take care of difficult tasks so that we as software developers, we don't have to worry about them. So there's library code to help with many common sorts of things that many applications will need, things like working with math or working with strings and text and working with dates, manipulating dates and times, maybe displaying things to the computer screen or transmitting information across a network. So a lot of that kind of foundational stuff that would be difficult for us to write and is utilized by many different applications. So that's really the first part, taking advantage and understanding the class library of the dot net framework. The second part of the dot net framework is called the runtime. It's also known as the common language runtime. You'll see it called as the CLR as well. And really, it's just this protective bubble that wraps around your application. Your application lives inside of it. It runs inside of that protective bubble. And it essentially takes care of a lot of the low level details so that you, the software developer, you can focus on what your application is supposed to do, not worry so much about how it's actually accomplishing it under the hood. You don't have to worry about the computer's operating system interacting with it and interacting with memory and interacting with the hardware, the computer itself. Many of those things are kind of abstracted away from you. You don't have to worry about them. Furthermore, the CLR, that runtime also provides a layer of protection for the end user so that you, the malicious evil software developer, you can't do something really bad to somebody's computer without them at least giving you permission to do it in the first place. So without their knowledge and their approval, you're not going to be able to wipe out their entire hard drive, for example. For right now, it's the dot net framework class library that I really want to focus on because it's what we used, whether you realize it or not, whenever we were writing our first application. So for example, in lines 13 and 14 where we did our work, you see console dot write line and then we used open parentheses, close parentheses and so on. We were using code in the framework class library that knows how to display text into a console window. All we got to do is say, hey, use this text, stick it in a window. And we don't really care how it does its job. We just care that it did it. And so the next line of code, this console dot read line, it was also really important. We're telling the application to wait for input from the end user before continuing its execution. So again, here we're calling code in the dot net framework class library that knows how to accept user input. We call that I use the enter key on the keyboard and then the application continued on, it exited and we were back in the visual studio. So in both of those lines of code, we were utilizing methods that were defined, that were created by somebody in Microsoft to handle that interaction with displaying and retrieving data from the end user. So what were to happen if we were to comment out that line of code? And here to comment out a line of code, I use two forward slashes on my computer. It's over the question mark. And commenting out code simply means that I want those instructions to be ignored. Now, I could have just deleted that line of code completely, but I might want it later. So maybe I don't want to remove it completely. I just don't want to, I just want to ignore it for now. I also might use code comments to write myself some notes to remind myself of something about the application in the future. We'll talk about code comments a little bit later. But if we were to run the application now, watch what happens. Okay, it ran and it's already done. What happened? Well, you might have seen a flicker on screen for like a fraction of a second. The reason was because, hey, it executed this one line of code. And it said, well, looks like I'm done here and it exits out of the application. By adding the read line, we're now stopping execution waiting for the end user to do something before exiting out. Okay, so hopefully that makes sense. All right, so next let's talk about the position of the code that we wrote. I made sure to emphasize that you have to write the code in the correct place. And the correct place was in the in between the opening and closing curly braces of that innermost set of curly braces as defined kind of by the by the level of indentation that we saw in the boilerplate code. So if you don't add the code there, we saw what the ramification of that was, right? The application, you'll try to run it. It'll give you a runtime error. The correct place for that code was where we have it right now in between that opening and closing curly brace that you see on screen. Now, as you can see, there's several sets of curly braces. And so it's important that we talk about what these do. And I need to oversimplify things here. We will come back and fill in some of the details later. But essentially, you have an opening and closing set of curly braces and those define a code block. And code blocks typically have names and they have purposes. So in this particular case, we have a first code block in this code block has the name main. And this particular code block is known as a method. And this particular method by convention is the very first method that's called whenever your application is executed. And so I don't want you to worry about these other words static and void and even the string in the args for right now. We'll talk about those later on. But this entire code block here as well as the line above it, they define something called a method and a method is simply a block of code that has a name. Now later on, you're going to come to realize that a method is so much more than that. But I want to use that as a working definition as we're getting started here. The method has a name and when you have a name, you can call a name and say I want you to execute. And so we'll talk about methods again a little bit more in a little while. This main method lives inside of another set of curly braces and that set of curly braces also have a name. The name is program. It's a class called program. And so you can think of a class as simply a container for all of the methods of your application. You can kind of keep the methods that are related to each other in separate classes. Now, what do I mean by related to each other? Well, that's really for you the developer to decide as you get deeper into programming, you're going to come to understand the thought process behind organizing your code. But that's a little ways off for now. Just trust me on that. Now, I said that a class was merely a way to organize your methods. It is so much more than that. And again, I'm way over simplifying this as we're getting started here. But the main takeaway for right now is that code is organized in curly brace containers and you have some blocks of code that reside inside of other blocks of code. And to kind of emphasize that, again, here we have another set of curly braces and this set of curly braces has a name as well. In fact, it's a namespace called Hello World, which happens to be the name of the application that we gave it. Again, keep things extremely simple here. A namespace is just another way of organizing code. Again, at some point, it becomes so much more than that, but let's keep it simple for now. So let's take a look at these lines of code and kind of illustrate these ideas about namespaces that contain classes that contain methods. Here, what we're doing whenever we're calling console.writeline is we're actually making a call into the .NET Framework class library. Remember, it's that library of code supplied by Microsoft. And we're saying in that entire library, there's a book and there's a chapter inside of that book that I want to reference. So in this case, we're saying that book is the console book, the class. And I want you to look at the chapter named writeline that has the definition for this method. All right, hopefully that analogy works for you. But we're looking inside of a library to find a class and we're going to call a particular method inside of that class. And by using its name, we can execute all the code that was written inside of that method. Same with the method that we're calling below it as well. Notice that there is a period that we use between the name of the class and the method name. And we use that, it's called a member accessor. It allows us to access a member of the class. Or in other words, now that we know what the book is, we can find out what chapter we want to reference. Hopefully that analogy works for you. Now, notice also that both, whenever we call the writeline method and the readline method, that they both have parentheses following them. Now, in the case of the writeline method, we're actually sticking something in between the opening and closing parentheses, whereas in the readline method we're not. But essentially, those parentheses are saying not only do we want to reference that particular class method name, but the parentheses mean I want you to actually invoke it, execute it, do it now. Okay, so that's the purpose for those parentheses. Now, we can say do it now and pass in information. Do it now with this stuff, with this argument. So we're passing in an argument to the writeline method and saying, we want you to do it right to write this to screen. And here's what we want you to write. So it's an input parameter to the method named writeline. Okay. Now, don't worry, we're going to come back to the notion of methods in the future, as well as passing values into a method like we did as we passed in the literal string hello world into our method here. Just know that whenever you see parentheses after a given word in your code, you should be thinking that that code is being called right now as we step through the execution of the code. Next up, let's talk about the semicolon. We've already kind of explained it in the previous video, but just to kind of emphasize it, notice that almost everything, even these statements at the very top, have semicolons with the exception whenever we're defining a namespace a class or a method. And we said at the time that the semicolons are actually similar to the period or exclamation mark or question mark at the end of an English sentence. It completes a thought in C sharp. Now, some programming languages like visual basic, for example, they don't really have this idea. They only allow one complete thought per line of code. However, with C sharp, you could you could do this what I'm about to do. Watch. Okay. Now I have both of those lines of code on a single line. All right. And if we run the application will work just as it did before. So the way that you separate or indicate that you have two different complete thoughts is through the use of a semicolon. Furthermore, we could put lines of code on separate lines like this. Now it wouldn't make sense in this case because the line of code is so short it actually makes it difficult to read. But sometimes when you have a very, very, very, very long line of code, you'll see me split that line of code into multiple lines. And still the application will execute. Now, in other programming languages, you wouldn't have that behavior. Because really white space and line feeds and things of that nature, they don't matter to C sharp. The only thing that really matters is to indicate a complete thought is a semicolon at the end of the line. Let me go ahead and get rid of all that. And the other thing that I want to mention here that you may have noticed is the level of indentation that you get automatically from Visual Studio. Now that's completely optional. And Visual Studio nudges you in the right direction. But essentially, even if you were to kind of come out here and we'll use the tab key several times and write the word console dot right line, something like that. And notice that that Visual Studio reinvented it for us. Why do you suppose it did that? Well, many people believe that indentation helps the readability of the code so that you can see what code container where code resides inside of the other curly braces inside of your application. All right. And so kind of along those same lines for readability sake, notice that there are many different colors that are used as text inside of this text editor window. You have these royal blue colors and these are my default colors. Yours might look a little bit different, but by default, I think you have some royal blue, some black. You have aqua color here. This is a dark red. You have some light gray and light blue. All right. And all of those are used to help you identify the parts of speech. I guess you can say inside of the code that you write. All right. We'll talk more about that as we talk more about the syntax of C sharp in an upcoming lesson. Okay. All right. So now that we've talked about the code that we wrote and its position and formatting in white space and tabs and all that sort of stuff, what I want to do is stop right now for this video. And in the next one, I want to talk about the files themselves, the file that we typed our code into, how that relates to projects and even solutions. What happened when we saved our project? What happened when we actually ran our project? And so we'll do that in the very next lesson. We'll see you there. Thanks. Hi. I'm Bob Tabor with Developer University. For more of my training videos for beginners, please visit me at devu.com. Next, we're going to talk about how code files are organized into projects and solutions and then where you can actually find these projects and solutions on your hard drive. So whenever we created a new console project, the program.cs file was opened for us automatically in the main area in Visual Studio. And that's one of the things that project templates do for us. Whenever we choose file new project and we see the new project dialogue and we choose a project template, they provide a great starting point for the type of application that we want to build. It includes files with boilerplate code, important settings and other resources that we might need whenever we're building that type of application. So as you can see, we're working inside of this file in the main area and there's a series of tabs. Again, this isn't intended to be an overview of Visual Studio, but it's important to note that the names of the code files that you're working on are contained inside of those tabs. And if you take a look over to the right hand side, here is the solution explorer window. And it has a tree like structure of all the items that are kind of contained inside of our project. Now, again, as I said at the outset of this course, this isn't intended to provide a tour of Visual Studio per se. And there are other resources on Microsoft Virtual Academy that can really help orient you to using Visual Studio and the various windows and functionality that it contains. But the solution explorer is probably the most important part of Visual Studio next to this main area where you'll usually see the text editor and other designer windows. So simply put, the solution explorer is our main navigational device to the other files and settings that comprise our program. So you can see here that there is a program.cs file. Now, if I were to close the program.cs tab in the main area, I can always get back to it and open it up again by double clicking it inside the solution explorer. Alright, you can see it's open once again. Now, files and important settings are organized into a concept called projects.  You can see there's a little C sharp icon next to it, letting us know that this is a C sharp project specifically. And projects get compiled into a single dotnet assembly, which we'll talk about later. Furthermore, one or more projects are organized into solutions and you can see in the solution explorer, we have one solution here at the very top solution also named hello world that contains one project. Now, in many cases as you're getting started, you're only going to have one project inside of one solution. But as you come to build more complex applications over time, it's highly likely that you're going to need to manage multiple projects that are somehow related. Now again, the reason might not be obvious at this point, but as you continue to learn C sharp and how to build more complex applications for large companies or for yourself, this becomes a crucial code management strategy. But just for now, except the fact that there's this extra layer of a solution and one solution can contain one or more projects. And the projects will contain then all of the code files and the settings and the like that will be used to create an actual executable program. So trust me, these concepts will become more important after we get past the basics. Now the big question at this point should be, where are all these projects and solutions and files actually stored on your hard drive? I mean, can we see them? We can see them in the solution Explorer. Where are they actually on your hard drive? Well, when we created this Hello World project, we merely provided the name of the project you'll recall. And then I said, go ahead and accept the other defaults by default, Visual Studio will put your projects into your documents folder. So if you take a look here and we navigate into the documents folder, it will put your projects into whatever version of Visual Studio you're currently using. So you can say I have side by side Visual Studio 2013 and 2015. We're using 2015 for this series, but it could be a future version of Visual Studio. You'll look in that particular folder for your version of Visual Studio. And as we drill in, there will be a projects folder. And as you drill in, you can see that by default when we created a new project, it put it here in our document slash Visual Studio, whatever version slash projects folder. Okay, so as I add more projects, this obviously will be filled up with folder names for those projects. And it's important to note that whenever you create a new project, you don't have to create it and put it right here. You can put it anywhere. And so to keep things organized, you're typically going to put them, keep them in the same place. Now, furthermore, you can actually open up a project that saved anywhere on your computer as well. So for example, I have this, in this course, I'll supply the projects after I record the video, I'll zip them up and you'll be able to download them and then open them up on your own hard drive and then walk through them and to better understand them. And so just to kind of demonstrate how you do this, I have this project called, is zipped up into a file called example.zip. And so what I'm going to do is actually right click this and select extract all. And then in the extract compressed zip folders, I'm just going to put this on my root. So c colon slash example, and then click extract. And so now you can see that on my local hard drive, I have an example folder. And inside of that folder, there is a another folder with a file called example dot SLN. I'll talk about that in just a moment. But I can either double click this dot SLN file to open up the solution inside of Visual Studio, like so. All right, or I could go to file open product solution and then navigate to that directory using the open project dialogue, if it'll let me. Okay. All right, and unfortunately, it's a little bit too large for the recording area, but then I would just simply select the solution that I wanted to open from this dialogue, and then and then click the open button. All right, let's go ahead and close that. And let's shut down this copy of Visual Studio. And I want to get back to where we were just a moment ago in our documents. Visual Studio in my case Visual Studio 2015 projects folder. And here are a list of all the solutions in our project folder. And so just kind of want to walk our way through this. This first folder here will contain our solution files. So there's this dot SLN file, which is a solution file. It contains information about all the projects that are under this umbrella solution. Okay. And we could actually open this up and look at it inside of notepad. And it's simply just a configuration file. There's nothing all that special about it. You certainly don't want to make any changes to it. But it's going to have information about all of the locations for the various projects that are associated with this solution. Any global settings and some of these things won't really be useful to us until we get deeper into our understanding of compilation and things of that nature. But inside of the solution folder is a second folder, which is actually going to contain the project files. And so here we have a hello world.csproj, which is the project file, the C sharp project file. And this file will contain, let's open that up as well with notepad. It'll contain references to things like all the files that are associated with this project and any of the settings and any other metadata. Again, information in here that you certainly don't want to edit and you don't want to accidentally make any changes to it whatsoever. But I just wanted to make you aware of it, that there's really nothing magical going on. There's just these configuration files that contain information about your project. And as you make settings on the project level, those will be saved inside of that CS project. And then finally there's this bin folder here and the word bin typically is short for binary, which denotes that this is where a binary version of your application will be stored. So the process of compilation, it takes your source code and which is human readable, and it's going to convert it into a format that is machine readable or understood by a machine, your computer. And so if we were to take a look inside of this folder, we would see that there is a debug folder. And so this folder is created for us whenever we started debugging our application. It creates a temporary version of our application for debugging purposes, which we'll talk about later. If we drill into that, you'll see that there is actually an executable file and several other helper files for the purpose of debugging. We'll talk about these later. If I were to double click the hello world.exe, it actually executes our application. And so compiling your code into a working application is the end goal. But I don't want to talk about compilation just too much yet or about creating a debug version versus a release version of your .NET assembly of your compile code. I think you're going to get a better appreciation for those ideas after we get past some more of the basics. So what I want to do is just stop our conversation about the VIN directory right now. We'll come back to that a little bit later. But you're doing great. Let's continue on. We'll start learning more C-Sharp now that we have some of these tangential topics out of the way. I'll see you in the next lesson. Thanks. Now in this lesson, I want to get back into talking about C-Sharp, the syntax. And we're going to talk about declaring variables, how to choose the right data type for your new variable, and then also how to initialize variables with values. So to begin, let's take a look on screen. If you've ever taken an algebra course, hopefully you've seen something like this where you're asked to solve for the value of X. And hopefully without a lot of thought, you're able to see that X equals 7, right? So using that same thought process, take a look at this little snippet of code on screen. X equals 7, Y equals X plus 3, and then we're going to do a console.writeLine with the value of Y. And hopefully you look at it for a moment. Using your existing knowledge of algebra and you think to yourself, then it's going to output the value of 10 to a console window, right? Exactly. And so my point is that C-Sharp, first of all, is human readable. It's got a few things that might be a little foreign to you like the semicolon at the end of the line. However, for the most part, I'm willing to bet that as we go through this series of lessons, you'll be able to understand what the code is doing for the most part, even before I explain it to you. So it's really not that hard. And then secondly, it's probably very similar to things that you've done in the past like working with math and algebra and things of that nature. And so if we're looking at the C-Sharp code, the X and the Y in this context are referred to as variables. And a variable is simply under the hood, a bucket, I guess you could call it, in the computer's memory. And you put things in buckets and you dump things out of buckets, right? And so we can put values into a given bucket in the computer's memory, and we can retrieve the value out of that bucket. We can even replace what's in the bucket with something different, right? And so that is what you use a variable for. And so this particular situation that we see on screen, these buckets are just holding numeric values. However, we could create buckets that are just the right size for almost any type of information, whether it be individual alphanumeric characters or strings of characters, strings of alphanumeric characters, like even entire sentences and paragraphs and even books. We could also create buckets that are just the right size for dates and times, buckets that are just the right size for really, really, really massive numbers, or even create buckets that are just the right size for numbers that have a lot of values after a decimal point. Now, in this case, what we would expect to see here is that these two buckets, the bucket that's labeled X and the bucket that's labeled Y, would hold numeric values because we want to add numeric values together, right? And so we know that, but how do we express that intent in C-sharp? The instructions that we write in C-sharp were ultimately, after a compilation step, they will ultimately be executed by the .NET runtime that we learned about in a previous lesson, and part of its responsibilities are to make sure to allocate memory for our variables in memory to hold the right kind of data. So here we have two data items, an X and a Y, and we have to tell the runtime that we want to allocate some space in memory that's sufficiently large enough to hold numeric data, like the type of data that we want to work with here and our application. But how do we do that? Well, that's the topic of this lesson. So to get started, what we want to do is create a new project. And here again, I'm going to go to File, New Project. We will go to the New Project dialog and make sure we select the Console Application Project Template. And here we're going to rename this and call this project Variables, and then click the OK button. And Visual Studio goes to Work, uses that template and creates a new solution with a project. And as you can see on screen, here we are back in our familiar program.cs. Obviously, we want to work inside of our static void main in between the opening and the closing curly brace, just like we learned about in our previous lesson. So before we get started, there's one big takeaway from this lesson, and that is that a variable is simply a bucket in memory that you can put data into and retrieve data out of. But we have to tell the compiler, we have to tell the .NET runtime what size of buckets that we want to create. So we have to declare our variables. We have to create those buckets and then give them some label that we can refer to them with from that point on. Now, before we get started here, typing some code, all the same rules apply in this video that apply previously. So you have to type the code exactly the way that I type it. Take the time, develop the skill of identifying differences between even small differences, a different in capitalization or in spacing or the various special punctuation marks that we use while we're writing code. Develop that skill to identify the differences between what I write on screen and what you're writing in your copy of Visual Studio. And if you see a little red squiggly line, you already know that there's going to be a problem there, right? So that gives you the clue necessary to go and focus either on that exact character or in that vicinity and use your detective skills to figure out what it is that went wrong. Okay, so now let's go ahead and we're going to create two buckets, two variables, and define them in such a way that they're going to hold numeric values. So we'll start with int x and int y, and it's as simple as that. So here to borrow the explanation that we used earlier, we are asking the .NET runtime to allocate space in our computer's memory sufficiently large enough to hold numeric values. Now we're asking it to create these two buckets, and eventually we're going to put values into them and read values out of them. But at this point, we're just declaring their existence and saying, here's what we need to work with. And then after we've declared that, after we've created them in this manner, then we can begin to work with them and assign values, retrieve values from them. But most importantly here, I'm telling the computer that I want to assign integer values into those variables. And an integer is really just a mathematical term that refers to a whole number that's within a certain range. So no values after the decimal point, and as far as C sharp is concerned, the values have to be between a negative 2 billion, 147 million, and a positive 2 billion, 147 million. That's the size of the bucket that we have to work with. If you need to work with much larger numbers, then the int data type is not the correct data type for you. There are other data types to choose from, and we'll learn about some of those a little bit later. If we needed to work with like money values where you have dollars and cents or pounds and pence, then the integer is not the right data type to work with. Let's continue in our application, and this is basically just to continue what we did in Notepad a few moments ago. So x equals 7, y equals x plus 3, and then we want to do a console.writeLine with the value of y. And then remember we want to do a console.readLine so we can actually see it on screen without it just flashing and going away immediately. So let's run the application and make sure we get the value that we're expecting. And hopefully you got the value 10 in your copy of Visual Studio just like I got in mine. If not, again, make sure you double check your work against mine. All right, so after we declared the variables in lines 13 and 14, then in lines 16 and 17, I'm doing assignment using the equal sign. Now in this case, we don't really call it the equal sign, we call it the assignment operator. We'll learn about operators in the next couple of lessons. This particular operator, the equal sign means take whatever is on the right hand side and assign that into whatever's on the left hand side. So we're going to say give me the value of 7 and assign that to our variable, our bucket named x. And the same thing would be true here with y. We're assigning a value into the bucket named y, but we have to do something interesting here. We have to actually retrieve the value of x from memory. So what was x again? Where's that bucket again? Oh, there's the bucket. Dump the value of the bucket out. You're holding the value 7. Add that to 3. And then we assign that to the value of y. Now here, we're retrieving the value of y saying, OK, give me the bucket with y in it. And you dump it out into the console.rightline, which we know, then we'll print that to stream. And that's essentially assignment and retrieval of variables. OK, so this is a very simple case. What I want to do now is comment out this code. If I were to begin commenting out the code like we learned about in a previous lesson, I could use the two forward slashes. I'm going to show you a different method in just a moment. But notice when I do that, something interesting happens. I commented out the declaration for the variable named x. When I do that, notice I get these little red squiggly lines underneath x's. And if I hold my mouse cursor there, it says the name x doesn't exist in the current context. And we might say, well, there it is right there. It's in our code comment. But remember, we're telling the C sharp compiler and ultimately the .NET runtime to ignore that instruction. So the compiler is looking at our code and saying, I have no idea what you're talking about x. I've never heard of x before. I don't know what you want me to do with x. And so it raises the red flag and say, I can't continue on under these conditions. You have to give me more information. Obviously, we can fix it by removing the code comments. All right. Now, what I want to do is comment out several lines of code. And instead of just doing two forward slashes in front of every line, which can be laborious, I'm going to comment out multiple lines at the same time using a forward slash and a star character over the number eight on your keyboard to begin a lengthy comment. And then right here before that read line, actually, let's go ahead and keep it all together. After that, I'm going to do a star forward slash. And so now we're going to type another code example beneath that. All right. This will be a little bit more interesting. Follow along. Pause the video if you need to catch up with me. I'm going to try and type fast just to save time. All right. And before I forget, let's go file, save all. Great. Now, let's begin here at the top. You can see that this is a different style application with some different commands or different uses of commands that we're familiar with. We're just going to play a little name game and we're going to ask what is your name and we output type your first name. Now notice in the first case, I'm using a right line, which will print what is your name to screen and then use a line feed character to go to the next line. However, I'm using yet a third method from the console object, the console class, which we'll talk about classes and methods later. But this method is different than right line. This will just write out the statement type your first name, whatever's in between our double quotes there. And it won't go to the next line. It'll just wait there on that line. And then what we're going to do is create a new variable using a different data type, a string data type. So we're not interested in individual alphanumeric characters. So A through Z, one through zero and the special characters. We're interested in a string of them or a collection of those characters. So not just the individual character B, the individual character O, and the individual character B, we're interested them as a string or a collection as Bob, B, O, B. So that's what we're declaring a bucket in the computer's memory sufficiently large enough to hold a string of characters, however long that it is. And then what I'm doing is calling our console.reline method that we're already familiar with, but there's a twist on this. Up to this point we said we're using the redline method in order to stop the execution of the application to wait for the user to hit the enter key on their keyboard then to resume. However, now we're using it for its real intent, which is to retrieve data from the end user. So in this case we're asking the question, what's your name? The user types it in and hits enter. And then whatever they typed in is assigned using the Simon operator to the variable we created called first name. Hopefully that makes sense. Now we're going to create a second variable of type string called my last name. We're going to do the same thing here, console.write, and then we're going to allow the user to type in their last name. And then whatever they type in when they hit enter on their, the enter key on their keyboard will be saved or assigned to the variable called my last name. Now that we've done assignment to my first name and my last name, I'm merely going to concatenate the values together. So let me point something out, there's several things we need to talk about here. Notice here we were doing actual math where we were adding values together. This is the arithmetic or arithmetic operator. We're basically adding things together, right? Here we're kind of adding things together, but that connotation is different. We're not adding hello and Bob and Tabor with some spaces in there from a mathematical perspective where concatenating strings of characters together to make one really long string. So it's the same operator, but it's used in two slightly different contexts. Kind of does the same thing, but we need to understand that there's a fundamental difference in how operators interact with different data types. You'll see why this is important as we continue on through this course. But at the very end here, we're expecting to see hello comma space Bob space. Notice that I have in here a additional double quote with a space in between to give some spacing between the first name and the last name. And then obviously my last name here, one more line of code to write because we need to do another read line so we can see the value on screen. Let's run the application and we have some things we want to talk about here. Okay, so what is your name type first name Bob enter type your last name Tabor enter hello Bob Tabor awesome. Okay, so very simple application, but hopefully now we're pushing the envelope a little bit more learning a little bit more about additional data types that we can use for our variables and learning about assignment that it works with all kinds of variables and then also learning about operators that work differently with different data types. Now before we get too far in the previous example we used merely X and Y which we might expect to see in some mathematical context because we're used to seeing those characters used in algebra problems. But whenever we start writing business applications or even games, we need to give our variables names that are meaningful inside of the program that we're writing. So I could have just used, you know, called this acts and then done something like this acts and then done something like this acts, and you look at this and you say I have no idea what X is supposed to do. All right. It's because we used a very vague description of the bucket in the computer's memory. Instead, you don't have to worry about keystrokes make it human readable. Write your code in such a way that somebody can read through it and understand exactly what the variables are doing and what the logic of the application is doing, and then also notice as I go and change some of these things back here to my first name. I used a little feature of Visual Studio that allowed me to say now that I have changed the name of X to first name, let me rename it everywhere that I've used the word X. Did you notice I did that? I hit the control on the period on the keyboard here. Let's do that one more time. I'm going to change this back to X. Notice that I get the little light bulb here off to the left hand side, which is quick actions, and then I hit control period on my keyboard. And now it gives me the option to rename my first name to X. And it even off to the right hand side shows me all of these changes. This is called a refactoring. I'm changing the code just ever so slightly by renaming things to give them more meaning. In this case, I'm doing the exact opposite, but we'll come back to that. So do I want to rename every time I use the variable name my first name to X? Yes. So let's rename everything. Bam. Just like that. All right. Let's rename it one more time. So my first name, control period, and now I want to rename everything from X to my first name. And you might look at that phrase, my first name, and then again, I used it down here, my last name, and you're thinking yourself, that's a crazy naming convention. Well, it's a naming convention that's called camel casing where you start with the first letter in a list of words that you're kind of munging together to describe a variable or something along those lines. Use a lower case for the first letter of the first word and then an uppercase letter for the second and subsequent words in that variable name. So ideally it makes it human readable. I can read it fairly easily that way. All right. All right. And at this point, I think it's important also to do something like this. I'm going to rename this to my first name, all lower case, and remember what we said in the previous video that C sharp is a case sensitive language. So if you were to use the wrong capitalization, then you're going to get a red squiggly line and it says my first name does not exist in the current context. Do you remember seeing that just a moment ago when we removed the declaration for for X up here when we commented it out? The same thing is true here. My first name all lower case is different from the bucket, the variable we define called my capital F capital name first name. All right. Capitalization matters. Make sure that you remember that. So in this case, let's just go ahead and change everything back correctly. And we should be good to go again. Okay, great. Now you might be saying yourself, well, this degree of precision seems pretty, pretty difficult. I mean, how am I going to remember exactly what I named things in the past? There are a couple of different tricks for them keeping your code methods small and we'll talk about that later. That's one way to do it. But then the other thing is to rely on IntelliSense, which is that little code window that I told you to ignore before. It's actually pretty important. So as I start typing my notice that it pops up beneath what I'm typing. The correct capitalization correct spelling for any of the variables that I've defined up to this point that start with the letters and why now at this point what I can do is simply hit the equal sign of my keyboard and it will type everything else out for me. So I don't have to worry about spelling. I don't have to worry about capitalization. And you may have noticed while I was typing, I was I was typing and then using arrow keys on my keyboard. And then you couldn't really see my fingers moving, but I wasn't typing every single keystroke. This is what allows software developers to write code very quickly. Once you get used to relying on IntelliSense, one of the tools that Visual Studio gives you in the text editor to make your typing more accurate and allow you to type much faster than maybe you normally could. Okay, we'll come back to IntelliSense later. All right. The other thing that I wanted to tell you about here or talk about is that we cannot define the same variable two times. So let's try this. I'm going to go and do my first name and say I want another bucket in the computer's memory with the same name my first name and the compiler says you can't do that. We've already got a bucket. We're going to confuse buckets in memory if we give two buckets the same name. Okay, so it says a local variable name my first name is already defined in this scope. You can't do that. Now we could do this, but I highly recommend you don't do that. Because again, my first name all lowercase is different than my first name with camel case. But this would cause a high degree of confusion. So never do that. Be descriptive with with your variable names. Don't repeat variable names. Always stick to a naming convention and never break that rule. And if you follow those little rules, I think you'll find some of these initial issues. They'll they'll just kind of dissipate. You won't have to worry about them. All right. Okay, so what I want to do now is take a look at this second set of code. And then not only are we in line number 2029 declaring the variable, but then in line number 31, we're actually giving it a value. What if we were to rewrite this little passage of code? So I'll go ahead and comment all of this out. And I'm going to make this smaller. In fact, here's what I'm going to do. String my last name equals console dot read line. And then I will say above that console dot write line type here. Okay, so you can see that I took these two lines of code 29 and 31 and I combined them together. And so what I'm doing here is not only declaring the variable, but then I'm initializing its value to whatever we retrieve when we call read line. So this is called initialization. And initialization is important because you want to give your variables of value as quickly as possible. This puts your variable into what's called a valid state, which will be an important idea as we learn to write applications, real applications. But also experienced developers like to write less code and they're always looking for a convenient way to reduce the number of keystrokes that they have to type and reduce the amount of code that they have to read. And so usually you want to declare your variables as you're using them and not declare them like some people used to do a long time ago, put them all at the very top of a given method or or section of code. And so you should get into the practice of two things. Declaring your variables as you need them in the body of your code. And then secondly, if you can give them and initialize value immediately after you declare them like we've done here in line number 34. Okay, so tell you what, let's stop right there. I think we've covered a lot of ground for one lesson, right? Let's do a quick recap and just talk about over a dozen things that we discussed. We talked about what a variable is. We talked about how to declare a variable, how to choose the correct data type. We talked about the int data type and the string data type. We talked about assigning values into variables and then retrieving values out of variables. We talked about the assignment operator. We looked at the arithmetic operator and also the string concatenation operator, which is both just the plus sign. We looked at console dot write versus console dot write line. We looked at the other life of the console dot read line method that we can actually retrieve the values that the user types in. We talked about camel casing and naming conventions for our variables. We looked at IntelliSense. We talked about how to rename things, how to refactor our code using the little quick action. Remember the little light bulb that we could make changes to by hitting control and period on our keyboard and then using our arrow keys to make selections and to rename all uses of our variable name throughout our entire code base. We probably talked about a lot more than that as well, but let's go ahead and wrap it up here and we'll start again in the next lesson. We'll see you there. Thanks. Hi, I'm Bob Tabor with Developer University. For more of my training videos for beginners, please visit me at devu.com. In this lesson, things are going to get a little bit more interesting. Based on user input, we're going to write logic to execute either one block of code or another block of code. When I use the term logic, I mean that we're going to make a decision to execute some code based on some condition that could be the user's input from the keyboard, maybe the state of the computer system itself, maybe some other data that we have access to or available to us, but somehow we're going to make a decision on whether to branch out and execute this code or execute this other code. So let's begin the way that we normally do by creating a new project and I'm going to go File, New, Project, make sure to choose a console application, C-sharp console application, and we'll call this project Decisions and click OK. And what I want to do is we're going to create a little game and we're going to do it right here in static void main and I'm going to go ahead and start typing. You can pause to catch up with me. Alrighty, so hopefully most of this will make sense. Let's go ahead and run the application. And here we're going to play Bob's Big Giveaway and we can choose a door. What's behind door one, two or three? I choose what's behind door number one and it said, hey, you want a new car? Awesome. Let's play again. I'd like to win something else. And so now we can type in the number two and, well, nothing really happens at all. I'm going to hit Enter again on my keyboard and the application just ends. We can try the same thing for three, but I suspect the same thing will happen with number two and I can just type something randomly and again, nothing really happens here. But let's start at the basics and talk about this if statement that we've created here, which is really the purpose of this lesson in the first place. The if statement is called the decision statement because we will decide whether to execute any of the code inside of this inner code block based on this evaluation that we're going to do after the if keyword. So in this case, what we're doing is evaluating whatever the user typed in and we're gathering that from the console.readline like we learned in the previous lesson. So the user typed something in the hit Enter. We got that now in the user value variable and we want to perform an evaluation to see if what the user typed in is equal to this literal string number one. All right. And so here's where hopefully I want to call your attention to this. You can see that I'm using two equal signs next to each other. So we already learned previously that a single equal sign is actually an assignment operator. We're assigning the value of whatever the user typed in in this case in the console.readline to the variable user value using this assignment operator. But whenever you use two equal signs next to each other, you're going to do an evaluation for true or false. So whatever's inside of this opening and closing parentheses, we're going to we're going to perform an evaluation is user value in fact equal to the number one or the rather the string character one, or is it not equal to the string character only be true or false. All right. And so based on that, if whatever the evaluation of that expression is, if it turns out to be true, then and only then will we perform the code defining the code block immediately after that if statement. If that's not true, if this turns out to be a false statement, then we'll just ignore whatever is inside of this code block and will continue the execution of our application to line 23 and then beyond. All right. So that's how it works. But I tell you what, this isn't a very interesting example, because obviously here we have we have no no prize for door two or door three. And then what happens if somebody is types in four, five, six or ASDF or whatever on the keyboard, we need to account for all of those scenarios in our application. So let me continue typing in some code here and you can again pause the video if you need to follow along, but we'll start by using else if statement right below our our code block for the if statement. Okay. So here we go. All right. Let's stop right there for the moment. And you can see that in order to evaluate additional conditions, I can use the else if statements. In fact, I have two of them here. So if this first evaluation is not true, then we'll continue on and do a second and a third and maybe a fourth and fifth. If this is true, then we'll no longer run any of these additional checks. We'll just continue on to line number 33. The same is true here. If this is not true, then we're going to evaluate this next expression. If this is true and we execute the code inside of the code block immediately following it, then we'll just go ahead and skip over this last else if statement and continue on to line number 33. All right. So if we were to run the application, let's go ahead and just quickly run through scenario number two. Okay. We want to vote and scenario number three, which obviously would allow us to win a cat, but then we still haven't accounted for the situation where we type in for or anything else like the word or just random letters on the keyboard. Nothing really happens in those situations. What we really need is what I would call a catch all case. And so to do that, we'll just create an else statement at the very end of our if else if construct. And so here what we'll do is just that string message equals. Sorry, we didn't understand and then console dot right line message. All right. So now we're catching every other case possible, no matter what the user types in. So let's go ahead and run the application. Again, I'll just type in some junk from the keyboard hit enter and says, sorry, we didn't understand. And we continue on. Okay. So that's how and if decision statement work. It also has these optional parts of the else if and the else statements for either additional, additional evaluations or what I call the catch all just in case none of the conditions are true. Okay. Now there's a couple of things about this and we're going to continue on to talk about one other type of decision operator that we can use a conditional operator. But before we do that, here's an opportunity to clean up our code. Let's let's look for areas where we've essentially got the same code repeated over and over and over again. And I can see a couple of instances where this is true. The first would be where we have this console dot right line message. You see we've repeated that in line 20, 25, 30 and 35 wouldn't be great to keep our code a little smaller. And only use that once at the very end of our evaluation, like put it right there outside of the if else, if else decision statements. All right. So let's go ahead and just remove those from there completely. All right. But when we do that, notice that I'm getting a red squiggly line under the word message. The name message doesn't exist in the current context. All right. So we're going to talk about scope and declaring variables inside of certain scopes and a little bit, but just to kind of lead up to that conversation. Essentially, when we defined a variable inside of an inner scope, it's not available outside of that scope. In other words, if we define a variable inside of a code block inside of the curly braces, it's only available inside of those curly braces, not available outside of those curly braces. So what we'll have to do is define that message variable outside of our if statements so that it's accessible to all of the inner code blocks as well as our console dot right line message here in line number 35. So it's a very simple fix. We'll just do this string message equals and then we'll just set it to an empty string to begin with. All right. So now you'll see a different message, a red squiggly line. But we've seen this before. You can't define the same variable twice, even if it's in an inner scope. So what we'll do is just say instead of defining the variable message there, we'll just set our existing string variable called message to the value like so. Okay. Great. So now our application should run. We've eliminated a lot of code and admittedly I created a straw man here. I wrote more code than I needed to, but I wanted to illustrate this point. So again, if we were to run the application, it works correctly, but there's one other change that we can make. Code blocks inside of as we're using them inside of if else if and else statements. If there's not more than one line of code to execute, then we don't even need to use the curly braces. In other words, since there's just one line of code here underneath my if statement, I can just remove it and make it small like that real compact. Same is true here. And same is true here. Now in this case, maybe just to kind of illustrate why you would need the open and closing curly braces.  Let's go ahead and test that that else case just real quick. And I'll type anything in there and hit enter and says, sorry, we didn't understand you lose. Notice that we were able to concatenate two strings together. I did it on two separate lines. Don't really need to. But if I were to attempt to remove the the opening and closing curly braces there, we're going to get a very different result when we run our application. So for example, if I hit three, notice that you want a new cat, you lose. Wait, what? How? Why did that happen? You want a new cat, but you lose? Well, well, there is no such thing as a free cat, but any rate. It's because what it's really seeing is this like that. All right. If we want these two to be evaluated together inside the same code block, we have to include them in the same code block. Otherwise, this being outside of that code block will execute no matter which of these if or else if conditions are true. All right. So let's go ahead and put that back in there to kind of illustrate that idea.  Let's comment that out. And I'm going to show you a new operator, which is just this. Okay. So now instead of going message equals message plus you lose essentially, I'm saying, give me whatever's in the variable message concatenate on the word you lose and then assign that back into the variable message. That's what I did here. I just do it all in one step right there where I say whatever's in the variable message on the end of that concatenate you lose. So this is the assignment and concatenation operator kind of combined into one. Okay. Just a little shortcut there. All right. So now let's do this. Let's talk about another style of decision statements. It's actually an operator called the conditional operator. And this works well if you have an if or else kind of scenario and you don't have multiple items to evaluate evaluate like we did here. So I'm going to copy some code from lines 14 and 15. Whoops. Yeah. And line 16. Let's just copy all of those and we're going to paste them down below our commented area. All right. And then what I'm going to do is this this will do this a little bit different this time. Okay. There we go. Now I've written a lot of extra code that I need to I'm going to show you how to shorten this up in just a moment. All right. So here the key to this is this little evaluation that I'm doing online number 42. Remember that we're going to evaluate anything in between of the parentheses whenever we see the double equal sign. That means we're doing an evaluation is the user value that they typed in and submitted through the previous line of code line number 40. Is it equal to the literal value one? If that is true, if this equates to true, then what we want to do is is everything after the question mark. We're going to take that value and assign it to our new variable called message. All right. So if the user types in one, we'll find the word boat, the literal string boat and we'll assign it to the variable message. However, if this equates to false, so they type in something different than anything after the colon will be taken and assigned to the variable. Message and we'll use that below. So let's go ahead and run the application. We'll run it twice. We can choose a door and if they choose door number one, they want to boat. However, if we run the application a second time and we choose anything else, then you'll only win a strand of lint. Again, this is only useful in a if else condition, not when you have multiple conditions to evaluate. All right. Now let's address this last little part here because I can shorten this up considerably. Notice in order to get it all to print out on one line, I only use console.write. And so then I typed out the literal string and then I have a second line where I'm actually then printing out the actual message from line 42. And then finally to add a period at the end, I'm having to do yet another console.write statement in order to add a period. Okay, I can shorten all that up in one line of code. Watch how I do this. In fact, let's go ahead and just I'll comment out these lines individually like so. And then I'm going to use a replacement character inside of the console.write console.write line in order to shorten this up a little bit. So we use a write line instead. And for U1A, and then I'm going to use what we what I call a replacement code. So a replacement code of zero. And then after I give it that literal string, I'm going to use a comma and then give it the actual message variable that I want. Whatever is inside of this, I want it replaced in here. Okay, so eliminate that, that the curly braces with the zero and put the message variable value inside of there. So let's run the application again just to see this working. I'm going to type in number one and get the same result. All right. Now what if we wanted to expand on this idea here? Comment that out. And what if I wanted to replace two values inside of that console.write line string? So let's do something like this. You entered and zero. Therefore, U1A. And so in this case, after the comma, I'm going to enter the user value and then the message here. Let's make sure you can see that. Hopefully you can see that all on screen one time. So I need to do one little thing here is change that to a one. All right. So this says take the first item. So in software development, typically you don't start with the number one. You start with the number zero. I don't know. So we're going to see this pop up again and again. So the first item in the list will be at element zero. The second item in the list will always be at element one and so on. All right. So the very first item, this will be matched and replaced by the very first item in that common delimited list of input parameters. After the literal string, that little template that we created for ourselves. Then here we're going to do a second replacement and replace that with whatever's inside of the message variable. So when we run the application and we type in the number one said you entered one. Therefore you want to vote. All right. Okay. So that's enough for one lesson. Hopefully you've learned a couple of important things in this lesson. First of all, we talked about the if decision statement as well as the else if and the else and how to do a comparison and evaluation between two values to determine true or false. If we're using an if statement and we're doing that evaluation, then anything, the code that is in the code block below it will get executed. If that evaluation is true, if it's not, it'll either drop down to a second subsequent evaluation or even do a catch all in the else statement. We talked about using curly braces for our code block versus when you don't need them. We talked about keeping your code nice and tidy and small. We talked about declaring variables inside of scope and inner scope and outer scope as defined by our curly braces for code blocks. We talked about the conditional operators being able to all in one line do a check for true or false. And if it's true, assign one value versus a different value to a new variable. We talked about format codes inside of literal strings for our console dot right line and how to replace those replacement codes with with variable values that we then also pass in in our console dot right line statement. Like you see here at the very bottom in line number 49. So again, cover a lot of ground. Hopefully this all makes sense. If not, rewatch the video. Just watch those portions that didn't make sense. Make sure you're typing in the code yourself so that you can come to some of these epiphanies as you're typing. Okay. All right, we'll pick it up in the next lesson. See there. Thanks. Hi, I'm Bob Taber with Developer University. For more of my training videos for beginners, please visit me at devu.com. In this lesson, I want to spend a bit more time talking about some smaller syntax elements of the C sharp language that you need to master. To understand how a properly formed line of code is constructed in C sharp. And in one of the previous lessons, almost like the first lesson, I said something to the effect that just like you use a period or question mark or exclamation mark at the end of a sentence in English to complete a thought. You also use a semicolon at the end of a line of code in C sharp to denote a complete thought. And kind of to extend that analogy a little bit, I may have briefly referred to C sharp syntax as having nouns and verbs. So I want to elaborate on these sorts of things and clarify what I mean by that in this lesson. So I'm going to talk about the basic building blocks and I guess you could say parsing the parts of speech in C sharp. So let's start off in the beginning. Statements are what you call complete thoughts in C sharp, typically one line of code. Statement is made up of one or more expressions and expressions are made up of one or more operators and operands. So we've seen a number of statements and expressions and operators and operands already, whether you realized it or not. So as we're taking a look at some of the previous work that we've done here, I've got the variables project from a previous lesson opened up. And so for example, you can see that essentially each line of code is a statement. Each of them are made up of one or more expressions. So here, for example, is an example expression. This happens to be a variable declaration statement made up of a operator, which in this case is a keyword int for the for the data type integer and then an operand, in this case, a variable name. We also use another operator, the semicolon for the end of the line of code. Another example would be here where we have an assignment where we're actually calling a method. So here is an operand. It is the name of a class and we're using the open close parentheses. Remember, these are operators. This is the method invocation operator. Then we're using another operator here, the assignment operator to assign this expression, the value of this expression to another operand, the name of a variable that we created. So we were to look through the code, we could continue to kind of parse out and understand what makes up operands, operators, expressions, and then entire code statements. Now, operands are similar to nouns. They are things like objects and classes and variables and even literal values. These are the subject, I guess you could say, of your statement of code. And they're pretty easy to remember because typically you give them names, you define the values yourself and so on. Now, operators are similar to verbs. They are things like the addition operator or the string concatenation operator. These are things that act on the operands in order to perform some action. And typically you're going to use the built-in operators, although you could create your own operators, kind of a little bit of an advanced topic, but there are actually quite a few built-in operators and you're going to need to memorize many of them. You're going to need to know how you come to express yourself in C-sharp. Now fortunately as you start out, you probably only need to know a handful to be productive. And so what I want to do in this lesson is to focus on a few that I think you're going to use probably 90% of the time as you begin learning and you can obviously add to that list as we continue. So I'm going to actually present these in a rapid fire fashion. I've created a very nonsensical application. You can open this up, download it from wherever you're currently watching this video or wherever you originally downloaded it from. I called this project Operator's Expression Statements and the application itself does absolutely nothing meaningful at all. And so all it really does is kind of show you some examples of the various operators and expressions that you'll come across whenever you're working in C-sharp. So at the very outset here you can see that I have a variable declaration. We talked about this already. I did something a little bit different this time where I've declared several variables all upfront as integers. So x, y, and b are all defined as integers. Just wanted to show you something a little bit different there by separating them with commas. It's an easy way to just to declare several variables of the same type all on one line of code. Now I typically don't recommend this, but you might see this around in use in books and on the internet. All right, so next up assignment operator. We've already seen the equal sign at work in that capacity. Note here in line number 22 and following that there are actually many different mathematical operators. We're only looking at the most basic ones, but there are also some advanced ones as well. But here we have addition, subtraction, multiplication, and division. And as I demonstrate here, you can use parentheses to actually change the order of operations. So these are not in this particular situation. The parentheses is not a method invocation operator. It's actually a how you would typically use it in an algebraic or mathematical sense. You would use it in order to specify the order of operations. So perform this expression first, then this expression, and then take the results of those two and multiply them together in that third expression and then assign them to the value of x. And then there are operators that are used to evaluate. We've already talked about the equality operator where we're using two equal sign next to each other to make sure that these two items are in fact equal. Here again, we're using parentheses and yet a different capacity to define the boundaries of our expression that will either equate to true or false. So x equals y is either true or false. We can use greater than. We can use the less than operator. We can use greater than or equal to less than or equal to all of these again should produce a true or false result. There are also two conditional operators that can be used to expand or enhance an evaluation and they can be combined together multiple times as I say here in the comments. So I could ensure that both x is greater than y is true and a is greater than b is true by using the logical and operator. There's also an or operator to say either x has to be greater than y or a has to be greater than b in order for this outermost expression to be true. So here's the logical or two pipe characters next to each other. And then I guess we've already talked about that inline conditional operator where we have some item that's being evaluated and then if it's true then we'll take the first value and if it's false then we'll take the second value and in this case we're assigning either car or boat into this message variables value. And then also wanted to talk about member access and method invocation. We're going to talk about object-oriented programming quite a bit later on in this series of lessons. But we've already said how the console was a class and classes are containers for a lack of a more robust definition for methods and the way that you access a member method of a class or an object is by using the dot or the period. Furthermore we talked about the method invocation operator here. We are invoking a method called write line by using the opening and closing parentheses. And in this particular case we're passing in an input parameter. Again we want to hold off and talk about input parameters and methods a little bit later. But as you can see here's a number of different operators and these are just what I would call a very baseline set. You need to memorize these so that you can express the most basic of C sharp commands and understand exactly what it is that you're trying to do. It's not an exhaustive list by any stretch of the imagination but you will probably need these about 90, 95% of the time. And then you can expand your vocabulary of other operators and keywords over time. So in each of these cases that we just looked at an expression is made up of a combination of operands which are things like the literal strings and variables and objects like the console class itself. And operators. So things like the addition operator, string concatenation operator, equality assignment operators and so on. And you use expressions then to form complete thoughts statements in C sharp which are how the actions or the instructions of an application are expressed to the compiler and ultimately to the dot net run time which executes your application. So why am I telling you all of this?  Well it will help you to understand why this is not a valid statement in C sharp. You can't just type X plus Y and then give it a end of line character and expect it to do anything. The C sharp compiler will look at that and say what are you trying to accomplish here? Have you lost your mind? What do you want me to do with all this? So fortunately in situations like these as you can see Visual Studio can catch these sorts of syntactical mistakes even before you attempt to run the application. And if we were to hover our mouse cursor over the visual guidance here, the red squiggly line, you can see that the fundamental problem with this line of code is that only assignment, call, increment, decrement and new object expressions can be used as a statement. So what's the problem here? Well this is not a properly formed statement. We're not assigning, calling, incrementing, decrementing or creating new object expressions. What? We're not formulating a complete thought a good sentence. I mean I could create an English sentence like this. The red ball, period. And you would say the red ball does what? Who has the red ball? Okay, we can understand that just because you use words doesn't mean you're creating a complete thought or expression inside of the English language. Same thing is true with C sharp. Alright, that's all I'm trying to say here. So for beginners, understand that there's a proper syntax just like there's a proper grammar in the English language. Understanding this is really a big step towards solving your own problems whenever you're phrasing C sharp instructions that the C sharp compiler will understand and accept and ultimately compile into code that will be run by the .NET framework. So here, let's recap what we talked about in this lesson. First of all, statements are complete instructions in C sharp. They consist of expressions. And a statement is like a sentence in the English language and expressions are composed of things like nouns and verbs. In other words, operators and operands. The operands are things like nouns. They're the subject or what we want to do something with. And then there are the operators which are more like the verbs. These will act on the nouns to perform some action. We said that operands are like variables and classes, literal strings. These are things that we get to name ourselves. They give the meaning to our application, whereas operators are for the most part built into the language and we have to memorize them. And so to start off, you might use something like what I've given you here in the form of a project for a cheat sheet. But I think you might just be able to walk your way through and rationalize your way through. Now that you understand that there's a proper way to format a line of code, you might say, okay, what do I need to do here? And you might be able to reason your way through the operands and the operators. I'm going to need a variable to contain some values. And so once I have created that variable in memory, now I'm going to need to assign it to something. Now, how am I going to get to that something? I'm going to need to take another variable and this literal value and I'm going to need to add them together with an operator. And hopefully you get the idea there. Okay, so I hope that this was a useful exercise. I think it's useful for beginners to understand that there are syntax rules and they're not so unlike what you're already familiar with.  And so when you see errors, sometimes it's because you type something incorrectly and then sometimes you may not be using the right forms of speech in a sense in order to express that complete thought at C sharp. Okay, so let's pick it up in the next lesson. We'll see you there. Thanks. Hi, I'm Bob Tabor with Developer University. For more of my training videos for beginners, please visit me at devu.com. In this lesson, we're going to focus on iteration statements, a specific iteration statement called the for iteration statement. Sometimes you're going to need to loop or iterate through a sequence of things to find something that you're looking for to find a successful match. And actually you're going to do this sort of data manipulation more than you realize. So you'll have to trust me that this is a very important tool in your toolbox that you're building. So as you can see, I've already taken the liberty of creating our project. I called it for iteration. Pause the video, go through the steps that you already know how to perform to create a new project, new console window project and catch up with me. I'm going to begin to add some code here on line 13 in just a moment. Now the syntax that we're going to write here in just a moment is possibly the most cryptic of anything that you've seen yet. And I'm going to be completely honest. Sometimes I get things a little bit mixed up myself, but don't worry after we've struggled through it once or twice. I'm going to share the little secret that I use to get it perfect the first time every time. So having warned you about the complexity of the syntax, I'm still betting that you could figure it out and read it even before we actually attempt to run the application. Even before I take the time to explain what each little bit of the application is doing. So let me write it out here and then we'll try that. Okay, very simple, at least very compact section of code here. Actually, you need one more line of code, right? There we go. Now we're ready for action. So what do you think that this code does? Okay, got a theory in mind? Well, let's go ahead and run the application and see if your theory is true. All right, you can see that we have a list of numbers from zero to nine and then we can hit enter to continue on. So we're using C sharp to execute this little block of code right here until a certain condition is true. At which point we will stop executing that line of code and continue on to line number 17. So this four statement says that we should begin by declaring a variable. We're going to call it I, we could call it anything we want to and we're going to initialize its value to zero. Now as long as I is less than 10, we're going to continue to execute the code below it in our code block defined by our curly braces. Each time that we iterate through will increment the value of I by one. So this little bit right here is probably the part that you probably wouldn't completely understand unless I explain it to you. Remember how we use the plus equal sign in order to automatically take the value of message and add something to the end of it and then assign it back to the value of I. Remember that a couple lessons ago? We're essentially doing that here. This is the increment operator. So we're going to increment the value of I by one. So again, we're going to initialize and declare a variable and initialize the value. Then as long as this middle part is true, we'll execute the code below. And once we finish executing, then we will increment the value of I and then do that evaluation one more time. If it's still true, then we'll execute this code again. We'll increment I. If this is still true, we'll increment it again and so on. So that's how it works. Yes, this is cryptic syntax, but if you can just separate the three parts in your mind by remembering that there's semicolons that separate them, that can help. You know you're going to need to start off with some counter of some sort. You're going to need a condition and then you're going to need an incrementer at the end. And again, I'll show you a way to remember this so you never forget it. But before we do that, let me comment out this line of code and give you a variation on this idea. This would be fun. So here we go. So you can see that I simply added inside of our code block for the for iteration statement another if statement with its own code block inside of it. And here we're checking the current value of I. And once we find something we're looking for where I is equal to 7, then what? We'll perform this code. What does this code do? Well, this part's obvious, but this break statement may not be so obvious. You use the break to bust out of or break out of the for iteration. So we're going to make it to the value where I is 7 and then we're going to hit the break statement and then we'll continue on to line number 23. Let's see it in action. It's not going to look all that exciting, but I got an idea. All right, it found 7 and it pretty much finished, right? I have an idea. Why don't we watch this execute line by line? And to do that, we'll use the debugging tools inside of Visual Studio, which we have not even talked about up to this point. And yet is probably one of the most important features of using Visual Studio as opposed to just using a text editor and a command line compiler. So to make this work, what I'm going to do is actually set a break point here on this line of code. Now, how did I do that? I just went to this left most column and I clicked in the column in that gray column and it created a little red dot and off to the right hand side. You see that that whole line of code is outlined in red. Now, there are truth be told a number of different ways to set a break point. Probably the easiest way to do it is what I just showed you, but there's also keyboard shortcuts and there's menu options as well. So for example, with my blinking cursor on line number 16, I'll go to the debug window and I'll select toggle break point. If we look over to the right hand side, you can also see that the F9 key will accomplish the same thing. Great. Alright, so now let's go ahead and run the application and see what happens. Alright, so immediately the application pops up before anything can be printed out to the console window. Notice that we have paused the execution of our code and we're paused right here on this break point. Now at this point, what I can do is I can do a lot of cool things. First of all, I can see what my local variables values are currently. I can also change the value of those variables. I can monitor those values. I can change which line of code will get executed next and a bunch of other things. Now this is not a series on debugging. I can easily spend an hour showing you a lot of cool little features. However, what I do want to do is call your attention to this little window at the bottom. Currently right now, we're in what's called debug time. With the application execution pause on this line of code, the next line of code that's going to execute is that line right there that's highlighted in yellow. I can look at these little windows like this locals window, for example. You can see that the locals window will contain any variables that are currently in scope at the moment. Obviously, args is something that we haven't talked about yet. Let's ignore that one. What I want to focus on is the value of i. Currently, its value is zero. How do I know that? Because I'm looking here in the value column. I can also see what the data type of i is. It's an integer. If I were to hover my mouse cursor over i, you can see I'd be able to see it there as well. If I were to go and pin down that value, I'd be able to monitor it as well in this little helper window. In fact, I can kind of drag it around here. Now watch what happens. Let me readjust some things here. I'm going to step through this line of code. Now there's a couple of different ways I can step through the code. I'm going to recommend that we only talk about step over for right now. When we learn about methods, we can step into and step out of. But for right now, this middle button right here, the step over or the F10 key on your keyboard is what we want. I'm going to click it once and notice that we jumped from line number 16 to line number 22. Why was that? The reason was because i was not equal to 7. We didn't execute the code inside of the code blocks underneath the F statement. And we jumped to the end of the four code block. Now let's continue just to step through this. You're going to see that we'll increment i by one. Now when we do that, notice what happened. The value of i changed from 0 to 1 and that change is indicated by a change in color. Whenever you see the color red, that means something changed in the previous line execution. The value of that variable changed from some of the value now to the value of 1. We can also see this in this little mini window right here as well. How it is now turned to the color red. Now that we've incremented, we're going to do the next check to see is i still less than 10? And here we're going to step one more time into our program. Here we're going to step in the line 14 which opens up our code block and we'll do another assessment. Is i currently the value of 1 equal to 7? No. So we'll jump out of that if block and continue on. And we can just continue through this exercise until we reach where i is equal to 7. Now truth be told, I don't have to keep hitting the step over button. I can just use this continue button. And this will just keep bringing me right back to the break point. This basically says continue running until you hit another break point. And so here at this point now I see that my i is equal to 7 and that's what I'm checking for. So things should get interesting right now. I'm going to go back to start stepping line by line through my code. And here's where I hit the console dot right line. And if I look now on screen it actually did write that to the console window. And now I'm going to step through the next line of code. And notice that it jumped out from the break statement outside to line number 23 outside of the force statement to the console dot read line. We can hit continue from that point on. Our application is still running until we hit the enter key on the keyboard and then we've exited out. All right, very cool. Now you may have found it laborious to step through a number of times or even hit the continue button a number of times until we found just the right condition. So what we can do is make this break point into a conditional break point. So to do that I'm going to hover over the little red stop sign. I guess you could call it in the left most column and I'm going to click this settings. And here this will open up a little break point settings window right in line in my code. It pushed all the other code down. Notice that it goes from line 16 here to line 17 way below it. And I'm going to add a condition. And whenever this expression, a conditional expression is true, then we'll break at that point. So in our case when I is in fact equal to seven, then we'll we'll break on that break point. Okay, you can see that when I hit enter on my keyboard, it's saved. And now I can close this. You can see that the little icon change from just a red stop sign to having a white plus symbol inside of it. So now when we run the application, notice that I is seven and that I is seven our little window here before we even stopped into our break point. And now we can continue stepping line by line through our code and continue on right. And we got our result and we can continue on. Okay, great. So again, I could spend an entire hour just showing you other cool little features that will help you debug your applications. But understanding how to set a break point, how to run your application to a break point, how to step through line by line, and then how to resume at least resume temporarily or continue by using the continue button. Those are the key concepts in debugging. All right. Now let's go ahead and it'll turn off this break point from now on what I want to do is just eliminated. I can do that one of two ways to completely turn it off. I can just click on it'll go away or I can temporarily disable it by using this little icon that was next to the gear that we clicked earlier. And now you can see there's a little outline in the left most column and an outline around the line of code that had the break point. But no longer are we actually going to break on that line. Okay, great. So let's do this underneath the four statement from before. But above the console dot read line. I want to I want to do what I promised you the very outset, which will show you a way a foolproof way that you can get the syntax right for a four iteration statement and truth be told for just about anything else by using a little secret code snippets. Okay, it's not that much of a secret, but you probably didn't know about it. Did you? Okay. All right, so to do this. It's real easy. If you can remember I need a four iteration statement just type in the word for you'll see that it pops up in the IntelliSense. And if you look after the IntelliSense pops up a little message to the right there code snippet for for loop note tab twice to insert the four snippet. All right, let's do it. Let's do it. Tab tab. Bam. And there we go. And notice that it went ahead and pretty much set it all up. Although there are some parts that we're going to have to change, like for example, the length, but I could also change. I don't have to use the value I for my iteration statement as my placeholder is my counter or whatever you want to call it. I could call something like my value notice as I'm typing and then I hit the tab key on my keyboard. It changed everywhere that was using the I variable label to my value. All right, very cool. Hitting tab also took us to the next spot in our code that we're going to need to replace, which was the length. Or in other words, how many times should this for loop iterate? And I'm going to say we'll do it until my value is less than 12. Now here again, we can use a number of different quality or any quality operators here. We don't have to use the less than we could use the equal or we could use the greater than whatever makes sense for our application. But I keep it simple and leave it just like that. Once I'm done making changes, I can sit at the end of my keyboard. There were some highlighted areas that were highlighted in gold color kind of that indicate that these are replacement areas. And now my mouse cursor is right between the opening and closing curly braces. And at this point, then I can continue to create my application right line and then my value like so. And then we can run our application and we would get the following results. Okay, so just to recap, it was a short lesson, but we learned a lot. Not only did we talk about four iteration statements and why you might want them and we'll see them at use later. But we also talked about the debugging tools just briefly and how to step through our code, how to monitor the value of variables, how to use the break statement to bust out to break out of a iteration statement. We looked at code snippets and how to replace values in a code snippet in order to make it our own. So we'll use some of these techniques that we learned here throughout the rest of the series. Very important video. And so let's continue on the next lesson. We'll see you there. Thanks. Hi, I'm Bob Tabor with Developer University for more of my training videos for beginners. Please visit me at devu.com. In this lesson, we're going to talk about arrays and I'm going to start by making a case for why you need arrays in the first place. So often you're going to need to work with several related variable values. But how do you work with multiple variables and kind of treat them all as if they're part of the same group? Well, let me show you how not to do it. You can see an example of that on screen. First of all, I've taken the liberty of creating a project called understanding arrays. So make sure you catch up with me, create a new console window application and you can kind of just follow along. And type this part in. It's wrong anyway. Okay, so you can see what I've done here. I need to keep track of five numbers and I need these numbers to be related to each other. So without any better tools in my toolbox, I might just create something called number one, number two, number three, number four and give them each a value. And now I want to find which variable holds the value of 16. I'd love to be able to loop through them like we learned about previously to find which of the values hold number 16, but I can't really do that. I'm forced to create an if, else if, else if, else if, else if, else if, else if, kind of structure as you can see here below in order to find, ultimately find which variable has the value of 16 inside of it. So this is not the right way to go about working with multiple values that are somehow related and you want to treat them as a group. There's a better way and that as you might assume would be with arrays. So we comment all of this out. And, you know, previously I talked about a variable as being a bucket in the computer's memory that will hold some value. But let's, let's expand our thinking about this for just a moment and talk about an array. Think of an array as like a bucket or maybe even better a tackle box.  All right, usually little worm or whatever the case might be. What if we were to use that instead of a bucket? Whatever we were to put values in each of those little tray areas inside of the tackle box and store that up in memory. And then whenever we needed a value out of that tackle box, we just need to take it and look through and find the particular compartment with what we're looking for in order to work with it. That's kind of the idea of an array at least if you want to overextend the bucket analogy. So another way to think of an array is kind of a sequence of data, a collection of data. Although I'm hesitant to use those specific terms because they have very specific meanings in .NET. So think of it in a very general sense. You have a collection of data you want to keep together. How do you do it? Well, one of the ways you can do that is with an array. So let's do this and I'm going to go ahead and create my first array here. I want you to follow along and notice that I'm using square brackets. I'm not using curly braces when I'm working here. So first of all, let's take a look at the declaration of our array called numbers. It is an array of integers. In other words, there are going to be multiple integers all collected under the same umbrella named numbers. And you can see that not only am I creating the declaration for this array, I'm also using an equal new int five. Some of this, like the equal and the new part, we're going to talk about what that really means a little bit later, but for now just accept it as how you go about creating an array. And then notice next to that I have int and then inside of that the square brackets I have the number five. So that's how many elements that I want inside of my new array. I want a new array of integers that can hold five values, five integers inside of them. Next, what I do is I begin to access each element of the array and put a value inside of that element of the array. So here's the first element of the array, the second element of the array. Remember, we're zero based. Here's the fourth element of the array and the fifth element of the array, five elements inside of the array, just like we defined here in line number 31. Now what if we wanted to access the value inside of one of the elements of the array? Well, I would do something like this. So console di right line, obviously. Now what if I wanted to get to and print out the value that's in the second element of the array? Well, then I would use the correct index of the array to access that element. So here, here's numbers and I want the second element, which means I'm going to use the index one. So I'm going to index into that array to get to the correct element. So in this case, the second element is at index number one. All right, and I can print that off the screen and we do a redline here like so. And we can quickly run the application and you can see that we are praying to screen the number eight, which in fact is the second element of our array. Now the other thing that we can do is actually determine how many items are in the array by looking at the length property of the array itself. So console that right line and I'll just go numbers dot length. And so let's see what that will output. In fact, let me go ahead and comment that out and run the application. So you can see that we're able to programmatically determine how many items are in the array by using the length property of the array. All right, there's five elements inside the array. Great. Now what were to happen if we were to attempt to insert data into another item, a sixth element of the array? What do you suppose would happen here? Well, we'll try it and we'll run the application and you'll see that we get an exception and index out of range exception was unhandled. In other words, we are outside of the boundary of the space that we defined inside of our array. We're trying to access compartments that were never created in the computer's memory inside of our little tackle box. So in order to remedy this, we can either redefine our array at the time of declaration that we need actually six items or we can go ahead and we can change at runtime the number of items in our array. It's a little bit of an advanced topic. I don't want to talk about how you would go about doing that, but it is possible to do it programmatically at runtime. All right, so let's move on from there and let's talk about maybe a simpler approach to creating new arrays and that is to not only declare the array, but then also initialize its values at the time of declaration. So let me comment out everything I have here and we'll do this. Now instead of giving it a specific size, we're going to let the compiler figure it out on its own because we're just going to start typing in the values of the elements that should be stored inside of our array. Now in this case, I can create it or just put all the items in there I want to put in there and I can trust that the new array that will be created in memory will be able to hold all six items this time. Let me comment that out and we've been working specifically with integers, but what if we were to work with strings? How would we go about doing that? Well, same sort of idea here. In this case, we want to give it a number of literal strings like so. And so let me move this over a little bit. You can see that we are able to create an array of strings. We don't have to declare upfront how many elements we want in our new array. We'll let the compiler figure that out. It will create four items. Now there's a number of different ways that we can loop through to access each of the items in our array. Let me show you two ways and one of them is going to be what you're already familiar with the for loop, right? So I'm going to go for a tab tab. And so we'll start with an integer i equals zero. And now let's do this instead. Let's go names dot length, right? And then inside of here we'll go let's do this console dot right line and we'll go names. And then what do you suppose we'll put in the middle here? We'll use the value i, right? So what we're going to do is start at zero and continue iterating through until we reach the length of our array. And then we'll stop and jump out of our array. But until then we'll do a console dot realign here. And you can see that this will allow us to print out all four items inside of our array to the console window. Great. Now there's a lot of management of this i here, but there's an easier way to go about this. Let me comment this out real quick. I'm going to show you a second style of iteration statement. So in this case we'll just do this. We'll do for each and I'll go ahead and use the code snippet. I'll just go tab tab. So for each string name in names. Alright, and I've made up the term name as singular in names is actually what we called our our array, right? So now I'm going to hit enter on my keyboard twice. And I'll just do console dot write line name. And let's go console dot read line. What this will do is it'll allow us to essentially loop through every single name in our array of names. And for each item it will copy the current element into this temporary variable called name of type string. And then we can use that to do whatever we want. In this case we're just going to print it off the screen. It's not much easier that is. But we can use either technique in order to iterate through our sequence of data. Pretty neat. Okay. All right, now let me show you one last thing you can do. It'll be pretty powerful stuff. And we can create arrays of different things, right? So what if we wanted to create an array? What if we wanted to take a string and reverse the string? Okay, how would we go about taking, for example, the name Bob Tabor and reversing that to, what, Robatt Bob, I guess. How would I convert? How would I change that? Well, what we can do is take a string and convert it into an array of individual characters. Once we have an array of individual characters, we can then say, go ahead and reverse the order of those items so that the last becomes first and the first becomes last. All right. So let's do this. I'm going to create a string called Zig. And it's going to contain one of my favorite speakers quotes that I have kind of patterned my life after. You can get what you want out of life if you help enough other people get what they want. All right. That's a very, very long line of code. So what I would probably do is I would try to chop this up into multiple lines of code. And we said this before that you can do something like this and see sharp. All I'm doing is going to just break it in half and use this concatenation operator, right, to kind of marry the first string and the second string together. So that's all one really one line of code. So now that I have this, what I want to do is create a an array of characters. So I'm going to use the char keyword, which is the data type char, meaning I want one character. But I'm going to create an array of characters called char array. All right. And then take this Zig string, and I'm going to call a helper method on it called to char array. So every, every data type has some helper methods that are built into it by the dotnet framework. And what this will simply do is take a long string and we'll split it up into individual characters and put those into an array of characters. Now that we have our, our statement here in an array of individual characters, I can do something like this. I'll call array dot reverse. I'm going to pass in the character array. And then finally what I want to do is do a for each tab tab for each char. And I'll just call this a Zig Ziglar char in my char array console dot write not right line, but just write and the Zig char. All right, hopefully all this makes sense. Let's do a console dot read line. And this is just to show you some of the flexibility of working with arrays. Let's run the application. And now we were able to write that whole, that whole string backwards. All right. So that's pretty much it. There's a lot more that you can do with arrays. However, as we move through C sharp, you're going to find that your use of arrays will diminish over time, and you'll start using something a little bit more elegant. Think of it as an array on steroids or maybe like super array. Okay, it's going to be called a collection. There's a bunch of different types of collections and we'll learn about those near the very end of this series of lessons. But at any rate, that's how you work with arrays. Remember that you have to declare an array by giving it at the time of declaration its size. Then you can access individual elements of array by using indexes into the array to access or to set the values in a given element of an array. We can loop through elements of an array using a four or a four each iteration statement. And we can even use some cool utility methods like array dot reverse to swap all of the items in the array, or there's also ways to sort items and so on. Okay, so let's continue on the next lesson. We're doing great. See you there. Methods are going to help us with a number of different things as we write more interesting applications. Methods are going to help us organize our code better. They're going to eliminate duplicate code and the need to copy something we did earlier and paste it later in our code base. They're going to allow us then to take a certain feature or functionality in our application and give it a name and then call it by its name anywhere in our application. And then if we were to ever need to update or fix an issue with our method with that code that's encapsulated in a method, we did to do one place instead of changing it everywhere we copied and pasted our code. So remember what we said at the very outset of this course that a method is merely a block of code as defined by curly br