C# For Beginners | Primorous Arts | Skillshare
Search

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

    • 1.

      Introduction

      2:46

    • 2.

      Chapter 1 (Setup): Install Visual Studio

      3:51

    • 3.

      Chapter 1 (Setup): Get Everyone On The Same Page

      4:07

    • 4.

      Chapter 2 (Hello World): Explaining The Program

      4:48

    • 5.

      Chapter 2 (Hello World): Writing To Console

      8:35

    • 6.

      Chapter 2 (Hello World): White Space

      2:28

    • 7.

      Chapter 2 (Hello World): Comments

      4:23

    • 8.

      Chapter 3 (Variables): Intro To Variables & Var Data Type

      6:23

    • 9.

      Chapter 3 (Variables): Integers

      8:03

    • 10.

      Chapter 3 (Variables): Floating Points

      5:41

    • 11.

      Chapter 3 (Variables): Booleans

      2:29

    • 12.

      Chapter 3 (Variables): Chars

      1:52

    • 13.

      Chapter 3 (Variables): Strings

      1:58

    • 14.

      Chapter 3 (Variables): Printing Variables To Console

      9:10

    • 15.

      Chapter 3 (Variables): Constants

      1:25

    • 16.

      Chapter 4 (User Input): ReadLine & ReadKey Methods

      6:40

    • 17.

      Chapter 4 (User Input): Convert.To Method

      4:32

    • 18.

      Chapter 4 (User Input): Parse Method

      2:32

    • 19.

      Chapter 5 (Operators): Basic Arithmetic

      3:52

    • 20.

      Chapter 5 (Operators): Increment & Decrement

      5:12

    • 21.

      Chapter 5 (Operators): Modulus

      2:25

    • 22.

      Chapter 5 (Operators): Assignment

      1:26

    • 23.

      Chapter 5 (Operators): Concatenation

      2:02

    • 24.

      Chapter 5 (Operators): Casting

      2:57

    • 25.

      Chapter 5 (Operators): Truncating

      1:23

    • 26.

      Chapter 6 (Conditionals): Scope

      3:16

    • 27.

      Chapter 6 (Conditionals): Intro To Conditional Statements

      1:12

    • 28.

      Chapter 6 (Conditionals): Relational & Equality Operators

      2:03

    • 29.

      Chapter 6 (Conditionals): Logical Operators

      1:41

    • 30.

      Chapter 6 (Conditionals): If Statements

      2:34

    • 31.

      Chapter 6 (Conditionals): Nesting If Statements

      4:47

    • 32.

      Chapter 6 (Conditionals): If-Else Statements

      3:10

    • 33.

      Chapter 6 (Conditionals): Else-If Statements

      4:46

    • 34.

      Chapter 6 (Conditionals): Switch Statements

      3:46

    • 35.

      Chapter 6 (Conditionals): Ternary Operator

      2:43

    • 36.

      Chapter 6 (Conditionals): TryParse Method

      6:06

    • 37.

      Chapter 7 (Loops): Intro To Loops

      1:47

    • 38.

      Chapter 7 (Loops): While Loops

      3:16

    • 39.

      Chapter 7 (Loops): Do While Loops

      3:09

    • 40.

      Chapter 7 (Loops): For Loops

      3:22

    • 41.

      Chapter 7 (Loops): Nesting Loops

      1:46

    • 42.

      Chapter 7 (Loops): Break Statements

      0:50

    • 43.

      Chapter 7 (Loops): Continue Statements

      5:34

    • 44.

      Chapter 8 (Random Numbers): Random Numbers In Programming

      2:24

    • 45.

      Chapter 8 (Random Numbers): Getting A Random Number

      5:42

    • 46.

      Chapter 9 (Collections): Intro To Collections

      1:56

    • 47.

      Chapter 9 (Collections): Arrays

      6:59

    • 48.

      Chapter 9 (Collections): Multi-Dimensional Arrays

      8:58

    • 49.

      Chapter 9 (Collections): Lists

      11:22

    • 50.

      Chapter 9 (Collections): Queues

      7:33

    • 51.

      Chapter 9 (Collections): Stacks

      8:05

    • 52.

      Chapter 10 (Foreach Loops): Intro To Foreach Loops

      2:41

    • 53.

      Chapter 10 (Foreach Loops): Foreach Loops & (Loops & Collections)

      14:39

    • 54.

      Chapter 10 (Foreach Loops): Dictionaries

      11:49

    • 55.

      Chapter 11 (Enums): Intro To Enums

      1:29

    • 56.

      Chapter 11 (Enums): Creating An Enum

      8:45

    • 57.

      Chapter 11 (Enums): Using Enums

      4:23

    • 58.

      Chapter 12 (Methods): Intro To Methods

      3:24

    • 59.

      Chapter 12 (Methods): Creating A Basic Method

      4:48

    • 60.

      Chapter 12 (Methods): Access Modifiers

      4:24

    • 61.

      Chapter 12 (Methods): Static vs Non-Static

      6:42

    • 62.

      Chapter 12 (Methods): Return Types

      3:17

    • 63.

      Chapter 12 (Methods): Intro To Parameters & Arguments

      3:24

    • 64.

      Chapter 12 (Methods): Value vs Reference Types

      1:51

    • 65.

      Chapter 12 (Methods): Null

      4:23

    • 66.

      Chapter 12 (Methods): Creating Parameters & Arguments

      5:27

    • 67.

      Chapter 12 (Methods): Pass By Reference

      11:19

    • 68.

      Chapter 12 (Methods): Optional & Named Arguments

      5:57

    • 69.

      Chapter 12 (Methods): Overloaded Methods

      4:09

    • 70.

      Chapter 12 (Methods): Arrays As Parameters

      5:01

    • 71.

      Chapter 12 (Methods): Immutable vs Mutable

      4:41

    • 72.

      Chapter 13 (Classes): Intro To Classes

      3:29

    • 73.

      Chapter 13 (Classes): Classes vs Structs

      3:02

    • 74.

      Chapter 13 (Classes): Creating A Simple Class

      4:22

    • 75.

      Chapter 13 (Classes): Instancing A Class

      3:19

    • 76.

      Chapter 13 (Classes): Class Methods

      4:56

    • 77.

      Chapter 13 (Classes): Alternate Class Creation

      2:17

    • 78.

      Chapter 13 (Classes): Constructors

      7:05

    • 79.

      Chapter 13 (Classes): Static Fields, Methods, & Constructors

      6:01

    • 80.

      Chapter 13 (Classes): Properties

      7:26

    • 81.

      Chapter 13 (Classes): Auto-Implemented Properties

      4:06

    • 82.

      Chapter 13 (Classes): Inheritance

      5:30

    • 83.

      Chapter 13 (Classes): Polymorphism Pt. 1

      5:05

    • 84.

      Chapter 13 (Classes): Polymorphism Pt. 2 & Array Of Classes

      3:59

    • 85.

      Chapter 13 (Classes): Interfaces

      20:54

    • 86.

      Chapter 13 (Classes): Four Main Principles Of OOP

      3:21

    • 87.

      Congratulations!

      2:06

    • 88.

      FAQ: Visual Studio License Expires?

      0:38

    • 89.

      FAQ: How To Properly Change Class Name? (Visual Studio)

      0:36

    • 90.

      FAQ: C# vs .NET?

      1:23

    • 91.

      FAQ: How To Clear Console?

      0:58

    • 92.

      FAQ: How To Change Console Colors?

      4:13

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

2,808

Students

1

Projects

About This Class

Description

In this comprehensive C# For Beginners course, I'll be taking you from having no prior programming knowledge, to confidently writing C# code of your very own, as we master the basics and even tackle advanced topics like inheritance, polymorphism, and interfaces. With step-by-step guidance, practical challenges, and clarification on not just what to do, but why, you’ll be on your way to building real-world projects in no time!

Why You Should Take This Class:

  • Versatility: C# is used in game development (Unity), mobile apps, websites, and much more.
  • High demand for C# developers: With an average salary of $100,000+ for skilled programmers, C# is a great starting point for a lucrative tech career.
  • Learn by doing: You'll get hands-on experience with coding challenges from Chapter 3 onward to help you apply what you've learned and solidify your understanding of the concepts taught throughout the course.

Who This Class Is For

  • Aspiring Programmers with no prior programming knowledge.
  • Anyone who wants to take their C# skills to the next level.
  • Programmers who need a refresher or simply want to learn a new language.

Materials/Resources Required

  • A computer (Windows, macOS, or Linux) capable of running Visual Studio or any C# IDE of your choice.
  • No prior programming experience is required.
  • All software used in the course is free to use.
  • I'd also highly recommend having a physical keyboard.

Meet Your Teacher

Teacher Profile Image

Primorous Arts

Course Instructor

Teacher
Level: All Levels

Class Ratings

Expectations Met?
    Exceeded!
  • 0%
  • Yes
  • 0%
  • Somewhat
  • 0%
  • Not really
  • 0%

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Welcome to the Primoris Arts C Sharp Course for beginners. If you are here, you are probably interested in learning to code, but feel a bit lost in where to start. I get it. I was there, too. When I first tried learning to code, I spent more time searching for a complete course, follow up content to what I had already learned and or answers to basic questions than actually learning. It felt like I was just being taught how to go through the motions when what I really needed and wanted was to know how things worked and when to use them so that I could get started on my own projects. That right there is why we created this course so that you wouldn't have to deal with those same struggles on your journey to becoming a programmer, where everything you need to get started is right here in one place from beginner to advanced topics with real support available when you need it most. So why should you learn C Sharp specifically? C Sharp is a powerful versatile language used in game development, mobile apps, websites, and more. With it, you'll have the foundation to start creating your own projects on a scale that is highly valued in the ever growing tech industry. Is also considered to be a very beginner friendly language based on the C language, making it easy to pick up and a great launching off point if you ever decide to transition to other C based languages like Java or C plus plus. So what are we going to cover in this course? Well, let me tell you. This course starts with the absolute basics. So if you've never written a single line of code, don't worry. We'll dive into fundamentals like variables, loops and conditionals, and gradually build up to more advanced topics like classes or objects, abstraction, encapsulation, polymorphism, inheritance, and from Chapter three onward, you'll be given the opportunity to get hands on with coding challenges specifically designed to help you solidify your understanding of the concepts taught throughout the course. So why should you choose this course specifically? Because rather than just showing you how to go through the motions and having you end up with some project that you have no idea how to recreate on your own, I'll be teaching you not only how to write the code, but more importantly, when to use it and why. By teaching you to think like a programmer, you'll actually gain a much deeper understanding of each concept taught so that by the end of the course, you'll be ready to tackle your own projects with confidence. And to make things even better, everything we use in this course is free, meaning there are no free trials or hidden fees to worry about. Now, who is this course for? This course is perfect for absolute beginners looking to get started, experienced programmers looking to refresh or expand upon their skills and everyone in between. And remember, there's no rush. Feel free to go at your own pace and to come back and revisit specific lessons when needed. Here at Primoris Arts, we are committed to helping you succeed every step of the way. So if you are ready to begin your coding journey, then there's no better time than right now. Invite you to join us today in the next video as we dive into programming step by step with clear, concise and easy to follow lessons. Thanks for watching, and I'll see you in the next one. 2. Chapter 1 (Setup): Install Visual Studio: In this video, I'm going to be showing you how to install Visual Studio is a free program available on both MacOS and Windows. So the first thing you're going to want to do is look up Visual Studio on Google, and it should look something like this. Now for those of you on MacOS, you're going to want to click the button here that says Visual Studio for Mac. And then click on this download button here. For the rest of you. While you're gonna wanna do is click here where it says downloads. Find the one that says Community, and click on the Free Download button below. Once you do this, it should start to install the program automatically. So the next thing you're going to want to do is go ahead and open that up. Hit Yes and or continue on any prompts that pop up and then wait for it to finish downloading. Once it is installed, it's going to ask you what workloads you want to download. If you're on MacOS, the one you want to download as dotnet Core. Otherwise, for those of you on Windows, you're going to want to click on the one that says dotnet desktop development. Now, if you're interested in any of the other workloads available, feel free to download them now. Otherwise, you can always download them later by using the Visual Studio Installer. Then once it is selected, go ahead and click Install and wait for it to finish downloading. Once it has finished installing, go ahead and open it up. And then what you wanna do is go ahead and create a new project. This portion of the video has been updated for 2022. Now, after hitting Create a new project, you should end up at a screen that looks like this. And the easiest way to find the project type that we're looking for this to go up here to the top where it says all languages and click on C-sharp. Then we're gonna go with the one that will run on Linux, MacOS, and Windows. So after you select that, go ahead and hit Next. Then we're going to want to give our project a name. And you can name this whatever you want. However, you'll want to use a Pascal Case naming convention. And to do that, all you need to do is help the very first letter is capitalized, and then every subsequent word, we'll start with a capital letter as well. And you're going to have no spaces in between. Now, if it's easier for you to read and you would like spaces between the words, then you'll want to use an underscore because you don't want any actual spaces in your project name. Anyways, go ahead and name that whatever you want. Then go ahead and choose the location where you want those to be saved. And you can leave it out the default location, or you can click on these three dots here to browse your files and choose a location of your own. Then we're gonna go ahead and leave the solution named the same. And if I mouse over this information simply here, you can see that a solution is a container for one or more projects in Visual Studio. Now, because we are just creating the one project, we're going to keep things simple and leave the name the same. However, in the future, if you ever creating a library of code, oftentimes you'll want these to be different names. Then we'll also want to make sure that this box here is unchecked. This as play solution and project in the same directory as this is generally considered good practice. Then we'll go ahead and hit Next. And you should end up at a screen that looks like this. Then we'll want to make sure to check this box here that says do not use top-level statements. Because if you do not do this, your code will not match mine throughout the rest of the course. Then we'll go ahead and hit Create. Once your project has been created and has launched, it should look something like this. So we've now installed Visual Studio and created our very first console application. So once you've reached this point, you are ready for the next video. Anyways. Thanks for watching, and I'll see you in the next one. 3. Chapter 1 (Setup): Get Everyone On The Same Page: So before we get started with any actual programming, I just wanted to make sure that you are at the same starting fans I am. So what I'd like for you to do is start the program by either pressing livelier, keep hard, going up to the toolbar here at the top and clicking this button. Or by going to the debug drop-down menu at the top and clicking start debugging. This should launch the console application I want you to do is say Hello, welcome to the top. If it did, great, go ahead and press any button to close out this window or click the X at the top. Now think did work. Great, you don't do anything, just sit back and follow along. If it did not work. What I would like you to do is go to the debug menu again and click options. And under the debugging general settings all the way at the bottom, there should be a checkbox that says automatically close the console one P by being stops, make sure that as unchecked and then click OK. Now if you are using Visual Studio and you run the console application, it should stay open and he should be good to go. If you're not using Reginald studio, which I highly recommend that as a free program, this may not have worked and will explain well. So what is happening is computers written three lines of code from top to bottom, reaching the end and then thinking it must be done. So like I was heading closest down. This happens in Sydney and which is why you may or may not know this, the complexification popping up at all. So to prevent this, we are going to add our first line of code. And I'd like for you all to follow along here as this may be useful information for you at some point in the future. It's just good practice. So what you wanna do is create a new line on your console dot write line. You're gonna wanna type console with a capital C. So as you see in the lineup of the capital R, C, capital K, open and close parenthesis, semicolon at the end. What this line does is it basically tells our programs that we wanted to wait for any key on my keyboard. So now when we run our program, it should stay open. Remember you can do this by pressing f phi when your keyboard going up here and clicking this button at the top, or going to debug, drop down menu and clicking Start Debugging. Now what it is doing is printing hello world and waiting for any t and put before a closing. For now, just realize that for any who weren't experiencing problems, but you'll have to press any key twice instead of once to close out of this. Or you can always press the accepted time. Now if you are still happening and you're using Visual Studio, you'll want to check over your code and make sure it looks exactly like mine. Helium line gnomic, nor is this one here, this namespace as every unions your program and should not be changed. Then you'll want to make sure it's also the latest version. And I've promised at Albert. Otherwise, if you are not using Visual Studio, I can do suggest that you check your code and then check the trainee further issues you might be happening. Now, I'd like for all of you to go ahead and save something you wanna make sure you do at the end of each and every video. Well, you have to do is file here at the top and click Save All. Anyways to the zip for this video. And the next one we're going to look at our program. It go over exactly what it is we're looking at. Does what it does. So thanks for watching and I'll see you in the next one. 4. Chapter 2 (Hello World): Explaining The Program: And thus video we are going to go over all the code we have here in front of us. Now this stuff is a bit more advanced. So don't worry if you don't understand all of that right now, I just want to provide you with a bit of insight as to what is going on here. So that as you continue through the course, you can start to piece things together. So the very top here we have the text using system. What the states in a nutshell is that we are using code from the namespace system. A namespace as just what it sounds like. It's a named space in which our application resides. Below this, you can see that our application has its own namespace. This is based on whatever you named your project when you originally created it. This is something Visual Studio does by default. Basically all I want you to get from that as let a namespace is a way of organizing code. You can think of this as being the equivalent of a last name. Just those people whose last names as another way to distinguish one another. A namespace allows the computer and us another way to distinguish various groups of code by using this using system Director here at the top. We no longer have to use the full name when using code from this namespace, which I'll show you here in a bit. So back to my last name example, destructive at the top would be like starting a conversation about a family. Once I tell you their last name, I don't need to repeat who I am talking about as their first names are now going to be associated with the family and of which I am referring to. Next, we have a class called program. This is made for us by default when we make a new console application. Real quick, C-sharp as an object oriented programming language. And an object is an instance of the class. Now a class is something modeled after real-world object, and it is made up of variables and methods, which we'll get into later. So let's use a light bulb as an example. Imagine we wanted to make a light bulb class. It might contain a single variable that tells us whether it is on or off, as well as a single method for turning it on and off. Now, if we have a box of light bulbs, each one would be a different object or an instance of our light bulb class. Hopefully that analogy works for you. Anyways, back to our program here, we also have a single method called main. Every program needs is allowed, one main method, and this is where our program begins its execution. So when our program runs and runs the lines of code and our main method from top to bottom. Our first line here basically tells a program to print out the text between quotation marks onto a single line and our console application. And as you can see, when we run our program, that does exactly what it does. Now we also have this line of code here that we added in the last video. This tells our program that we want it to wait for some sort of key input before continuing. How does it know to do this? You may ask, well, let me tell you, just as we have our namespace with the class called program and a method called main. There is also a library of code with a namespace called system and a class called console, which contains both the right line and the red key methods. Now how do we not use this system here at the top? And like I said, you can think of this as sort of like a last name. We would have had to type system, console dot write, line, and then the rest of the text here. However, since we already have it here at the top, we no longer need to write it down here as it already understands where this console class is coming from. Now there's only really a few things I want you to really understand for right now so that you can continue throughout the course. One as that 99% of the code that we'll be writing is going to take place between these two curly brackets. And that this line at the bottom tells her program to wait for some sort of key input before continuing. I realize not all of you need this line of code, but it isn't going to hurt anything and it will be leaving it here and every program for those who do just to simplify things. In the next video will be both editing and writing new code in order to print whatever we want to the console. So thanks for watching and I'll see you in the next one. 5. Chapter 2 (Hello World): Writing To Console: In this video, we're going to be learning how to print text to the console. Now if you remember, I had mentioned that our console dot write line here, prints whatever is between these two quotation marks to the console on a single line. Now this is one of the two main ways you'll print text to the console. So let's start there. As we already know, this will print Hello World on a single line. And as essentially the equivalent of typing hello world exclamation point and a word document, and then pressing enter or return at the end. To prove this, let's go ahead and copy this line of code. Creates a new line below it, and paste it again. Then let's go ahead and run our console application. Remember you can do this by pressing F5, clicking this button here at the top, and we go into the debugger drop-down menu and clicking Start Debugging. Now as we predicted, you can see that it printed hello world on two separate lines and the cursor is at the bottom. Next thing we're going to do is edit this code. So let's go ahead and delete one of these lines of code. Then what you'll wanna do is delete the text here between the quotation marks and write whatever you want. I haven't run the console application again. And as you can see at us, printed but we typed on a single line. Now, what if you didn't want to print on a different line? At the moment, you might not see a reason for this, as you can always just add more text to the previous line of code. But later on when we start getting into user input, you'll see why this is useful. So let's go ahead and write a brand new line of code. So we'll create a new line on our console dot write line. Then we're going to type console with a capital C dot, right? With a capital W, open parenthesis, two quotation marks, and then close parentheses, and lastly, a semicolon. Every statement, also known as an action in c-sharp, either ends with a semicolon or a closed curly bracket. Depending on the weather is made up of a single line or a block of code containing multiple lines. If he worked forgot the semicolon at the end, you would get an error and your program wouldn't run. So let me go ahead and show you what that looks like. So as you can see, a says there were built errors and asked if I would like to revert back to the last successful build. I'm gonna go ahead and click now. Now at the bottom here is going to pop up any error codes and backup here, you can see that there's a red squiggly line where the code was detected. Now, there's a million different errors and C sharp, so I'd never be able to go over all of them with you. But if you ever do get an error, you can go ahead and copy and paste this Eric code until Google and look it up. And you shouldn't be able to find out what it means. Most of the time though it is probably because you misspelled something, didn't capitalize it properly or forgot to endless statement where you shadow. So I'm gonna go ahead and paste the semicolon back in. Anyways, enough about errors, let's go ahead and move on with the lesson. Now, as it stands, if I were to run my program and it's gonna print the very first line and then a blank line because I don't have any text between microbes. Now, let's go ahead and put some text between these codes and our console dot write statement. So forget to put whatever you want here. Then let's go ahead and run our console application. So as you may notice, or cursors setting out the end of our second line of code. Whereas before it was dropping to the bottom. This is because whereas the console dot write line method was equivalent to us typing text up in a Word document and hitting Enter at the end. A right method simply prints the text, leaving our cursor at the end. So let's go ahead and close that out. Next, let's go ahead and copy our console dot write method, create a new line below and paste it. Then we'll run our console application again. And as you may have expected at presented the same exact text right after the last. Notice that it doesn't help you out by adding any spaces or punctuation or showing you any problems with your text. It just does what it's told. So that is something you'll want to be mindful of. Anyways, let's go ahead and close this back out. And I'm gonna go ahead and erase our copied line. The console dot write line method and the console dot write method are the two main ways you'll be printing to console and C-Sharp. Lastly, when I'm working with a string in C sharp, which you can just think of as text. The backslash as a special escape character that basically tells her program that the next character is a special character where it should be taken literally. So let me give you an example of how this might be useful. So something you may not have thought about as typing a quotation mark, as it normally signifies the end of our text here. But by using the backslash and then a quotation mark, we can actually type a quotation mark, as you can see here. Notice that the backslash is not printed the console. Next, let's go for a female characters that you can put in here. First off, you can put two backslashes because the backslash is considered a special escape character. You need to type two. The second one tells our program that we actually want to print a backslash. And as you can see when I run the program, that's exactly what it does. Next, we have backslash, lowercase t. This tells our program that we want to insert a tap and or the equivalent of five spaces. And lastly, we have backslash, lowercase n, which says that we want to make a new line. If you are in macOS instead of Windows, this will be backslash r. Keep in mind that using the backslash or the special escape character only tells our program to check the very next character for another meeting. So when creating a new line in this way, putting a space after the end would cause your program to put a space on the brand new line, which is why I do not have a space between the N and the S on the word second. And either you can see when I run our program, it works just like a solid. Now I do understand that we could have just created a new console dot write line statement instead of using the backslash and to create a new line of code. But that could eventually get messy in terms of readability, especially when we start to work with bigger programs. And you always want to do everything you can to make your code is easy to read and as understandable as possible. So that you can not only understand and easily read it now, so that you could do the same tomorrow a week from now, a month, or even a year. And hopefully so that someone else could take a look at your code and understand it as well. This is a core concept in programming and something I want you to remember in practice as we continue throughout this course. Now, though, I do believe the following me along exactly will help when it comes to any mistakes you may have. I also understand we had type things might not always be the easiest for you to understand or visualize properly. So feel free to change things to your preferences a bit. But if it becomes an issue, I recommend just following along exactly for now. But later on when you create your own code that you can go ahead and change it up a bit. And the next couple of videos we'll be going over ways to help achieve readability by using comments and by utilizing whitespace. So thanks for watching, and I'll see you in the next one. 6. Chapter 2 (Hello World): White Space: In this video, we're going to be talking about whitespace now and the C sharp language spaces, tabs and new lines are all considered to be whitespace. And it is generally ignored when the program runs because the compiler or the thing that turns our code into the console application doesn't really care about whitespace. And this simply use to make the code more readable to you, the programmer. However, there are some exceptions to this case. Two of the main ones being names in strings of text. First things first, let's go ahead and erase this backslash n here. Then to show you an example of where whitespace does matter, go ahead and put a space between the NMDA as I'm a name console here. And as you can see, when I try and run the program, it gives me an error. Then the other is strings o texts. So like up here, all these spaces are going to be printed to the console. However, like I said, in most cases, spaces, tabs, and new lines are considered whitespace and are generally ignored when the program runs. So, for example, we can go ahead and create as many new lines as we would like in between our lines of code. And the program will run just fine. And just to prove what I was saying before, spaces and tabs are oscillating in art as you can see here. Like I said, the way space is just for your convenience to make your code as readable as possible for you. Now I'm gonna go ahead and show you a kind of ridiculous example of using whitespace just to show you that it does not make a difference. And as you can see, the program still runs just fine. Anyways, throughout the course, I encourage you to use whitespace here advantage and make your code as readable as possible. However, and assess becomes an issue. I encourage you to copy my text exactly until you become a little more comfortable with programming. Or just wait until after the course when you start to go on your own and make your own programs. And the next video we're going to go over another way to make your code more readable by using comments. So thanks for watching, and I'll see you in the next one. 7. Chapter 2 (Hello World): Comments: In this video, we'll be talking about comments, what they're for, and the syntax for them and how to write them. However, before we get started, I'd like you to go ahead and erase all the lines of code above our console.log statement. Then above our console.log statement. You're gonna go ahead and type console with a capital C, right line with a capital W and L. Open parenthesis. Quotation marks, close parentheses, and a semicolon at the end. Then, in between our quotation marks, I would like you to type hello with a capital H, space, world with a capital W. And I'll exclamation point at the end. Now though I encourage you to type out console dot write line for awhile just to get some practice in, I am going to show you a little trick. So go ahead and create a new line under our console dot write line statement. Go ahead and type C, W, and then press the tab button twice. And as you can see, it automatically puts in our console dot write line statement for us. And all we have to do is either quotation marks. This can save you a tremendous amount of time in the future. Anyways, let's go ahead and erase that. Anyways, back to comments. So a comment and programming is a section of code that has completely ignored when the program runs, sort of like whitespace. This was extremely helpful for explaining your code and for testing purposes. To turn a line into a comment, you simply want to put two forward slashes. So let's go ahead and do that. Let's create a new line above our console dot write line statement and forward slash, forward slash. This tells her program to ignore the rest of the code in front of it on this line. So for example, let's say we wanted to make with this line of code here does more obvious at a glance. You might type something like this. Print hello, world to console. As you may have noticed, this line of code here is a different color than the rest of the program, in this case being green in order to show that it is a comment. Another way to create a comment as the highlight, all of the lines of code you would like to come out. And then to go to the top and click this button here. You can also click on the button next to it to un-comment this selected lines. The last method I have for you is forward slash Asterisk, asterisk for its Lash. And this will ignore all the lines of code between the two asterisks symbols, allowing you to start an NDA comment wherever you would like, either on a single line or across multiple lines. To demonstrate this, let's go ahead and type a forward slash and an asterisk before our console dot write line statement. And as you can see, although the lines of code in front of it happening commented out. To end this, we will put another asterisk and afford slash. Let's go ahead and do this after console.log statement. And as you can see, all of the code after it is not commented out. Anyways, let's go ahead and undo that. So let me go ahead and show you how it is useful for testing purposes. So let's say that I wanted to see how my program would run without a line of code or if you were to run at all. Although I would have to do as comment it out instead of deleting it entirely. So for example, we had comment out our console dot write line statement here, and then run our program. And as you can see, when we run our program, there is no longer anything being printed to the console. And I'm going to go ahead and undo that. Anyways, what I'd like you to do is to make sure that code looks exactly like mine. And then when you're done, go ahead and save your program by going to file at the top and clicking Save. All remembered that day this after each and every video. And the next video, we're going to be going over what exactly variables are in programming and how to write them. So thanks for watching, and I'll see you in the next one. 8. Chapter 3 (Variables): Intro To Variables & Var Data Type: In this video, we'll be talking about variables, a variable and C-sharp as a name given to a storage area. So it stores data of a various type. In other words, it has a name we give to some type of data so that we can both referred to it and manipulate it in the future. So for example, let's say we are making a pinball game. We might want to store a whole number and call it score. The syntax for creating a new variable is as follows. It is the data type by the name. And lastly, a semicolon at the end. Now, there are multiple data types for storing all sorts of things, such as whole numbers, floating point numbers, single characters, strings of characters, and our text, true or false values and Mark will be going over all the basic ones individually in the upcoming videos. Next, let us get into some more examples and break down the syntax for declaring and initializing variables in different ways. For right now, we are going to use VAR for our data type. Var is short for variable And just means that we want the compiler to figure out what type of variable we need. For those of you who don't know what a compiler is. It is what turns our code here into binary so that the computer can understand it. As a computer only understands ones and zeros. Anyways, back to variables. So let's start by simply declaring a variable. To-do lists. Remember, we need to type the data type followed by the name. And lastly, a semicolon. So let's say we wanted to make a variable to hold our ammo count in an FPS, we might type something like this. Far space ammo count, and then a semicolon at the end. Now when you name your variables, there are some things you need to keep in mind. First, you want to make sure that you give it a descriptive name, not something generic like x. That will make your code harder to read. And when you start working with larger programs, you aren't going to remember what x means. So don't do it. You can't have any spaces in your variable names. However, you can use underscores as a decent substitute. Also, notice how he typed out ammo count. This way of typing is called CamelCase. This snake case are both accepted naming conventions and programming. Camelcase is where you have 0 spaces or punctuation. The first where it begins with a lowercase or uppercase. And any subsequent words begin with a capital letter. Snake cases similar, except you separate the words without underscore instead. Let me comment this out quick and show you what that would have looked like if her to use snake case. Here would look something like this. Anyways, I'm gonna go ahead and undo that. So you can use whatever you prefer, either chemical or snake case. But in this series, I'll be using CamelCase. And that's because it is more common. Then next thing to know about naming variables in C sharp is that there are special keywords that you can not use as names. Here's a list of them now. Now, don't get too overwhelmed by that as I've never run into an issue with any of them. And you shouldn't either as long as you are using descriptive themes. Plus, you'd get an error if you try to use any of them. Anyways, as we continue through the course, I will provide you with more proper naming conventions so that you'll learn to code properly. Now, back to our ammo variable. Let's go ahead and initialize it and are given a value to do this, all we have to do is put an equals sign the after the name followed by a value. Unless case, let's say RAM account to 30. Now, there is another way to declare and initialize variables, which I'll show you in the next lesson when we work with our very first datatype. Next, let's test and see that we actually created a variable called ammo count and set it equal to 30. Now, if you remember, one way to print the console is to use the console dot write line method. Also real quick, I'm gonna go ahead and move the console dot read keyed method down to the bottom of my program. Before we had used the console dot write line method to print text, as you can see above. But we can also use it to print out the value of our variable. So let's go ahead and do that. So under our new variable, will type console dot, write line, open parentheses, and then close parentheses. And lastly, semicolon. Now instead of putting quotation marks in here to signify that we are working with text, we can simply answer our variable name. Now what this plan will do is print the value of our ammo count variable on a single line. And as you can tell, when we run our program and doesn't need print 30. So let me quickly go of her is all happening here. So first we created a variable which sets aside a certain amount of memory based on the data type. Then we gave it a name so that we can access and modify it later. Next, we initialized it by saying that we want our variable or the name. We gave a storage area and memory to hold the value 30. Because we used fire hazard data type, the compiler automatically figured out what type of data type we actually needed based on this value, which is why it says it represents a 32-bit signed integer. We will get into integers more in the next video. Then, lastly, we went ahead and printed that value onto a single line in the console. Now, because we only implicitly told the compiler what data type to use, we had to initialize our variable on the same line. How do we explicitly told the compiler what data type we need IT? There would have been multiple ways to define and initialize our variable. We'll go over these other options in the next video when we talk about integers, a data type for storing whole numbers. Anyways, thanks for watching, and I'll see you in the next one. 9. Chapter 3 (Variables): Integers: In this video, we're going to be talking about integers. And integer is a data type for storing whole numbers. The two main ones you'll be using our Signed and Unsigned 32-bit integers. A 32-bit integer is abbreviated to end in C-sharp and will be referred to as such from here on out. Now to start things off, I want all of you to erase all of the code and your main method, except for our console dot read line. You guys don't have to write down the rest of those text here. I'm just going to leave it here as a reference for you guys. Now the difference between us signed and unsigned int as whether or not it can store a negative number or it go below 0. A signed int can go below 0. And an unsigned int cannot. You can think of it like this. If they were asking for permission and needed you to sign something, for it to go below 0. And you send now and didn't sign it, it would not be able to do so. So unsigned ints don't have permission to go below 0. And signed ends have permission to go below 0. And Sir signed by default and can normally store any whole number in this range here. And then unsigned and consider any number in this range. Which for those curious, is the same as adding the two numbers together from the signed end, assuming they're both positive. Now if you didn't need to store a larger hole number or only needed a smaller one. There's other integer types which I'll show you now. As you can see, there are multiple integer types that take up different amounts of memory, as well as have the ability to hold a various range of whole numbers. However, since they are less common and unnecessary in most cases, we aren't going to dive into them. And of course, I just wanted to make sure that you are aware that they exist just in case you were to ever see or meet them in the future. But most of the time, and it will work just fine. They are awesome, more efficient. Anyways, let's go over some examples of using ends. So in the last video, we worked solely withhold number variables. However, we left it up to the compiler to figure out what type we need it by implicitly saying what data type we needed by using the keyword var. Now we're going to explicitly do it. And this is what I'd recommend doing most of the time if able. So now that we are explicitly typing our variables, we can go ahead and declare them on one line and initialize them on another. So let's do that now by making it into a variable called score. So if you remember to declare a variable, all you have to do is type the datatype being int, followed by the name being score. Then lastly, a semicolon at the end to end our statement. Now you may have noticed this green squiggly line here on our variable name. And basically all these are just kind of a heads up. If we mouse over it, you can see that it says that the variable score as declared but never used. Now that your program will run just fine as is. Those are just letting you know that as of right now you don't technically need this variable. But as soon as we use the variable score for something, this will go away. Next, let's go ahead and initialize our variable on a separate line. To do this, all we have to do is type the name, followed by the equal sign or the assignment operator. Then a value. Let's go ahead and make this 20 followed by a semicolon at the end. Next, let's declare and initialize a variable on the same line, just as we did in the last video. So on a separate line, let's go ahead and create an int variable called Health and set it equal to a 100. Now, I just want you to be aware that both of these are technically correct and will lead to the same result as far as declaring and initializing a variable. Though, I recommend initializing your variables before using them. And as soon as you can, just to avoid any potential errors. And it is just good practice. Now, if you know an integer variable isn't going to go below 0, you might as well make it unsigned. So let's say we were making a game and we know our health friable was never going to be negative. We can make this an unsigned int by putting the letter you in front of the word. And, and now that it is an unsigned integer variable, it will no longer allow us to make this a negative number. So let me go ahead and show you that far to set this to negative 100 out immediately getting air. Basically saying that I cannot set an unsigned int to a negative value next to. Let's go ahead and print both of these variables the console, just to show that they both work on a new line, we'll type console dot write line. And I do recommend new type this out just to get some practice in. And inside our parenthesis, we'll type the variable score. Then we'll do the same thing for our health. Then when we run our program, it should put the value of score being 20 on one line and the value of health being on another. And as you can see when we run our program that does exactly what it does. Then throw out things up. I wanted to show you how we can declare multiple variables of the same type in a single statement and even initialize them if we so chose to. The syntax for this is the data type followed by the name of her first variable, comma, then the name of our second variable, comma, and so on. And you can keep doing this for as long as you want it. Then when you create the name of your last variable, you put a semicolon at the end. So for example, let's say we were making a soccer game. I wanted to make two separate score variables. We could do that like so. We can say n score Team Red, comma, score Team Blue. And then lastly if semicolon at the end. And then if we wanted to initialize any of these variables, we could do so by putting the assignment operator after the name, followed by the value. And you could do that on all of them. None of them are just one or the other. Now in our case, we'd probably want to initialize them both to 0. So let's go ahead and do so. As you can see, our program will run just fine. Now just to show you something, because code is read from top to bottom, we would not be able to put score Team Red and this line of code lattice because it has not yet been declared. So if we did when I print out any of these two variables, we would have to put the code down below. Then I'll go ahead and run a program. And you can see that they were both initialized and print out just fine. Anyways, that does it for this video, we'll be working with ends again here soon when we get into arithmetic. And we'll also be working with them quite often throughout the course. This was just a brief introduction to them and their uses. And the next video we'll be going on for floating point types are numbers with a decimal point. So thanks for watching, and I'll see you in the next one. 10. Chapter 3 (Variables): Floating Points: In this video, we're going to be talking about floating point types. Now before we get started, go ahead and erase all over the code inside of your main method except for a read a key line. This is something we are going to start doing from here on out, unless otherwise stated. Anyways, floating point types are for storing numbers with a decimal point. Though they can store whole numbers, integers are more efficient at doing so. Now, in c-sharp, there are three different floating point types, which I have listed for you here. As you can see, each one has a varying range of numbers that they can store, just totally integer types. They also provide different levels of precision and take up various amounts of memory. Now the flow and the double types serve roughly the same purpose, and you will likely use and see both quite often when working with floating point numbers. The main difference being that doubles take up twice the space and memory as a float. And that they are more precise. That being said on numerous systems, doubles should run better and therefore, I'd recommend using them as your default for floating point type. Now, the decimal type, on the other hand, is mainly used for finances and by scientists and stuff like that, where they need everything to be extremely precise. For most other applications though, they are just slower and take up more memory. Unless you really need the extra precision. I'd go with a float or a double. Next, let's go over how to properly declare and initialize each one. So let's start by creating a new flow variable called Walk speed that holds the value 2.5. So today that will type flow space walk speed equals to 0.5. Then the last thing we have to do as out of suffix based on what floating-point type we're using, which for a float type is enough. So at the end of our value, we simply put an app to indicate that this value, we just typed. This in fact a flow for sluts or compiler. Now the way when I work with a float, not a double or a decimal, a float. Then just put a semicolon at the end. Next we'll create a new line and we'll create a double called run speed and set that equal to 10.2. And just for the hell of that, let's go ahead and declare that and initialize lists one on two different lines. Just to show that we can remember you can do this with any variable type, soil type double space, running speed, semicolon. Then on a new line will say that we want to set R1 speed equal to 10.2. And remember to do that, we just type the name of the variable that we're referring to, followed by an equals sign. And lastly the value. Then the suffix for a double is a d. Though this was not technically necessary as the default floating point type as a double. And lastly, to end our statement, we'll put a semicolon. Lastly, let's go ahead and create a decimal variable called Money and set that equal to 5.004 for school. And so you got And we'll take our data type, followed by the name. Then an equal sign, or the assignment operator, followed by the value, or 5.2004, then decimals or soft. And lastly, a semicolon at the end. Now, another thing I wanted to show you is that let say you are working with a very large number, whether it be an integer or a floating type, there is a way to separate out the numbers to make them more readable. So to demonstrate this, I'm going to go ahead and create a double called bank balance and set it equal to 10 thousand. Then I'm going to go ahead and separate the thousands places from the hundreds with an underscore. There's this creatively called a digit separator when used to separate numbers. This will help them making your numbers easier to read and it will not affect your code in any other way. Then let's go ahead and print all for variables to console on separate lines just to see that they are all working as we expected. Saturday This will take console dot write line, followed by an open parenthesis, our variable name, close parentheses, and a semicolon at the end. And then we'll go ahead and repeat this process for the rest of our variables. And as you can see when we run our program and it prints all four values to console on a separate line. Notice that the underscore from our bank balance variable did not show up in console. So you now know how to declare and initialize the different floating point types. Anyways, that does it for this video, we'll be talking about floating point types more here, sin when we get into operators. And the next video, we're going to talk about Boolean types, which are her storing true or false values. So thanks for watching, and I'll see you on the next one. 11. Chapter 3 (Variables): Booleans: In this video, we're going to talk about Booleans, data type for storing true false values. So for example, let's say that we were creating a game and we wanted to store a variable that would tell us whether or not it was game over. We could create a Boolean or a bool for short colleague game over and then set it equal to false. So let's go ahead and do that by writing. Gameover equals false. And then a semicolon at the end. Then down below, what's there on some texts to roughly similarly gameplay. Suppose say console dot write line. And in quotation marks will print data variable. So say console dot write line, GameOver. Let's print out x i equal to true. And lastly, let's print out our variable again. Now when we run our program, it should print out start pulse. You're a shot. And lastly, trim. And as you can see when we run our program, that does exactly what it does. Now, I'm sure you can think of a million examples of where it'd be useful to know whether or not something was true or false. Like whether a button was pressed, if our character was in the air, and if we were reloading, etc. And you can do all of that by simply creating a bool and then having all sorts of logic to determine what state your bool isn't. Anyways, that is it for this video. And the next one will be going over the char data type, which is used to store a single character. So thanks for watching, and I'll see you on the next one. 12. Chapter 3 (Variables): Chars: In this video, we'll be talking about the char data type. This is used to store a single character. So let's go and create a char variable called the single butter and set it equal to a to D two, this will simply type char when they met single letter, followed by the assignment operator. Then when working with chars, you need a surround the value with single quotation marks. Then we'll put in the letter a, followed by another single HCO and a semicolon at the end. Then we'll go ahead and print out our variable to console using the console dot write line method. And when we run our program, you can see that it prints out the letter. By the way, one thing to know is that when working with chars or strings, which we'll get into in the next video. As your values are case sensitive. So for example, we could change the value of our single letter variable to a capital a. And when we run the program, you can see that it was capitalized. Another thing you should know about chars is that behind the hood, a chart is actually a numerical value as each character has a specific number set and the Unicode alphabet. Now, the useless for chars will become more apparent later on down the line. But for now, I just wanted to make you aware of their existence. Anyways, that is it for this video. And the next one will be going over strings, which has a data type for storing multiple characters. So thanks for watching, and I'll see you in the next one. 13. Chapter 3 (Variables): Strings: In this video, we'll be talking about shrinks. Shrinks are a data type for storing text or a collection of characters or chars. Now, I'm sure you can already think up a 100 reasons why you might want to store some text for using and manipulating in the future. For example, you could use a string distort character dialogue, error messages, someone's name, item names, etc. So let's jump right into how to declare and initialize a string. Now, in the past, we've actually worked with strings every time we've printed text to the console. However, we've never actually stored it anywhere. We've just simply printed it. So let's create a string called name and then go ahead and set it equal to whatever your name is. So today that will type string name equals. And then in quotation marks, you'll type your name. And lastly, we'll put a semicolon at the end. Now, one thing to note is that we could technically store a single character in our string or even no characters and just put the quotes. If we had wanted to, for whatever reason, then let's go ahead and print our string to the console. But this time let's use the console dot write method. We're simply using the console dot write method. Just the show that you can print out variables with this method as well. Anyways, as you can see when you run your program and will print out your name. You've now learned all of the basic predefined data types. In the next video, we'll be going over multiple ways in which to print out variables to the console. So thanks for watching, and I'll see you in the next one. 14. Chapter 3 (Variables): Printing Variables To Console: And in this video, we'll be going over multiple waves to penetrate boast to the console. First, let's create a few variables that describe ourselves. So to start off, let's create a string called name. Then go ahead and set it equal to your name. Then we'll create an int variable called age and go ahead and set that equal to how old you are. And lastly, we will create a double called the hay, and we'll set that we're having. Next. We're going to go over a few ways to print all of at least to console and describe what it is that we're printing. So first we'll type console dot write line. Then in quotation marks, we're going to type a colon and a space, followed by the plus symbol and then the variable name. Then don't forget your close parentheses and a semicolon at the end. Then let's say the same thing for our height. What I'd like you to do is go ahead and run the application to make sure it works. By your name, your age, your next. Let's go ahead and print out the exact same thing in a single statement. But before we do so, let's go ahead and print out a blank lines. To do this, we'll type console dot write line twice, and we won't have anything in-between our parentheses. Now, to print all of this single statement, you have to do is type console dot write line, followed by an open parenthesis. And then a quotation mark will say name. Colon space. Quotation mark, the plus symbol, name. Then we'll do the plus symbol again caused by quotation marks. And inside the quotation marks were gonna tape backslash. And remember that the backslash is a special escape character. And that the lowercase n signifies that we wanna create a new line. Then we'll simply add another plus sign quotation marks, followed by the word age, and so on until we're finished. Then we run our program. And see that we printed the exact same thing twice. Now one thing that I'd like to go over with you, which we're going to start adding to our code in order to make it more readable as a concept called pseudocode. Pseudocode as basically a way of writing your code in plain English. This is something you want to start doing before, during and after writing code to make your code more readable. At-a-glance, though, for example, here at the top, we might write in a comment variables to store our name, age and height. And down here we can say something like print our name, age, and height to console. And down here we can say print to blink lines. In here, we can say that we want to print our name, age, and height in the console again. From here on out, we're going to start writing pseudo-code one viable. So let's go ahead and do that. And another comment line. Let's go ahead and say print blank lines. And then on the next line which create another comment and write and our name and height to consult again. Then just go ahead and copy and paste that. So now that we can easily see what we plan to do with our program, all we have left to do is to write in the code. So below this line here, we'll type console dot write line twice. Then what we're gonna do is we're going to print out our name, age, and height again, except we're gonna be using a process called composite formatting. To do this, you have to do is write console dot, write line, and Len inside of your parentheses, you're gonna wanna put quotation marks, followed by a name and a colon, followed by an open curly bracket. The number 0 and a closed curly bracket. Well, if this number is 0 here is as an index. And you always want to be sure to start at 0. Then after the close curly bracket will simply write backslash n H colon space, open curly bracket to number one and a closed curly bracket then, and we'll just do the same thing. Height. Then after your last close curly bracket, you wanna put in your quotation mark, followed by a comma. And after the comma, you want to write your name variable or the variable that will take up index 0, comma, comma, height, close parenthesis, and then a semicolon at the end. So what this will do is it will automatically insert each variable into the corresponding index run. When you run your program, you should see that you have now printed the same thing three times, but in three different ways. Then it will print another two blank lines. And then the last method I have for you is called the strain interpolation. To do this, all you have to do is write console dot, write line once again. Then setup parentheses way you wanna do, and it's pretty pen your string with the dollar sign symbol. With this does was a teller program that we want to use string interpolation for the following string. Then you want to enter your quotation marks. And inside of those, you're pretty much going to follow the same exact syntax that you've heard about. So we'll say name, colon space, followed by an open curly bracket, except this time, instead of inserting an index, all you have to do is insert the variable name, then a close curly bracket, followed by backslash n, age, and so on. And lastly, don't forget to end with a quotation mark followed by a closed parenthesis and a semicolon at the end. And notice that we didn't put a space before or after our backslash n, as it would have printed to the console. Then when we run our program again, you can see that we have now printed the same thing four times, but in four different ways. Remember that this method here is called string interpolation. But this one here is called composite format. You've now learned multiple ways to print variables to the console and how to print multiple variables using the same statement. In the next video, we'll be talking about constants. So thanks for watching, and I'll see you in the next one. 15. Chapter 3 (Variables): Constants: And in this video we're going to talk about constants. Constants can be numbers, boolean values, strings, or a null reference. Will again No, no oscillator. A consonant is used when you have a value that you don't want to change ever. So for example, you might want to make your max health and again, a constant. Keep in mind that a constant is not technically a variable because it cannot be modified. So let's go ahead and create a constant integer called Max Health and set it equal to a 100. And all we have to do is use the const keyword before our variable. The credit or max held constant. Const. And Max house equals a 100. And as you can see, if we were to try and change our max, how we would get in there. Because like I said, constant cannot change. Then let's go ahead and print max health the console, just to see that it worked. And as you can see when we run our program had done. And in the next video, we'll be going over collecting chars and strings from user input. So thanks for watching, and I'll see you in the next one. 16. Chapter 4 (User Input): ReadLine & ReadKey Methods: In this video, we'll be talking about getting user input using the console dot read line method and the console dot read CKY method. Now, what the readline method does essentially is record a string from the time it is called until the user hits Enter or Return. Then one to those done recording the string, it returns the string value and the read method obtains the next character or function key pressed by the user. But before we begin, we're going to start off by writing some pseudocode. So first we're going to ask the user for a name. Then we're gonna save the name as a string. And lastly, we're going to print the name. And the top part here. Let's start by saying console dot, write line, then water for their name. So I'll say What is your name? Colon space. Then we need to save the user's reply and a string. To do this, we're going to use the console dot read line method. So, and we'll say console with a capital C, just like above. Then we're gonna say diarrhea line with a capital R. And don't forget your open and close parentheses and a semicolon at the end. And like I said, this line here is going to record a string from the time it is called until the user hits enter or return. But we still need to store the string value inside of a variable. Otherwise we'll leave it. So write buffer method, we're gonna create a new string and set it equal to whatever this method here returns, which is going to be a string as well. So we'll say string. Let's just call this name and set it equal to this method. And lastly, we need to print the name back to the user. So once again, we're going to say console dot write line. And quotation marks will say your name is colon space. Then we'll just add on their name using the plus sign. Like so. Then let's go ahead and run our program. So as you can see, it asks for a name, can type whatever you want, and hit Enter. Then it's going to print that back to us on a new line. The reason it is on a new line as because we've had a hit enter or return at the end. Then I just want to show you that something else will work as well. And that is that we can change this top line here to console dot write instead of console dot write line. And this will work just fine as well. The only difference being is that world type her name on the same exact line as less. And you can see how that plays out if we run our program here. So it says what is your name? We type it out on the same exact line. Via Enter and it prints it out for us down below. And lastly, let's quickly go over how we can do something similar. Except this time we'll be storing a char value using the console.log method. And to keep things simple, we'll just leave everything the same. I just want to show you how this is done. So instead of saving the name as a string, we're going to save it as a char value. Then we're going to say console dot read key with a capital K instead of console dot read line. And notice how we got an error. And this says that we cannot implicitly confer from type System.out console key info to HR. Now, don't worry about this too much right now, as we'll be going over how to explicitly convert values later on in this course. For right now, I'm just going to show you another way that we can get a char value using this console dot read CKY method. And we're going to do this by accessing a property within the method. And we'll be going over properties later on as well. For right now, just follow along with means. So you can see the syntax that we are using to access the property that we need in order to get the right data type for HR using this method. So right after our console dot read key method here, make sure this is before the semicolon. We're gonna be using the member access operator or the period symbol. So will say dy. And then we're just gonna say key char with a capital K and C. Like I said, this here is just a property inside this method that holds the proper value we need for HR. Just like we access this read method inside of the conflict class using the member access operator. We were able to do the same thing with this key char property inside of our read CKY method using the member access operator as well. So let's go ahead and run our program. Right now. It's gonna ask for our name. Then as soon as we type one letter. And so I'm actually going to print that back to us. And that's because console.log key only obtains the next character type. And because we don't have to enter or return, it didn't print that on a new line. So if we wanted to clean this up a bit, so we could say console dot write line below here, create a new line when our program again. And as you can see, it now works a lot better. And obviously if we wanted to clean this up a bit, we can say what is the first letter of your name? And say the first letter of her name is, et cetera. So you now know how to get user input as a string and as a char value using either the console dot read line method or the console dot read method. And just remember when storing a char value using the console direct key method. You'll also need to access this char property. Or you could explicitly convert the value from this to a char. And we'll be going over how to do explicit conversions a little bit later on in this course. Anyways, that does it for this video. And the next video, we'll be collecting userInput again, except this time, we'll be getting a number instead of a string value. So thanks for watching, and I'll see you on the next one. 17. Chapter 4 (User Input): Convert.To Method: In this video, we're going to be going over a way to collect a numbers through user input will be doing this using the convert to method. So essentially what we're going to want to do is we're going to want to ask for a number. Then we're going to want to save that number. And lastly, Well one and print it out. So an example of what we might ask her as someone's age. So we can say console direct line, vendor start things off, will have to collect the string that they just type them. String. We'll call it numbered type. And we'll set it equal to console dot read line. Then we're going to use the convert TO method to turn whatever they typed in into an integer value. So we'll say int number, say convert with a capital C dot two with a capital T And with a capital I, the number 32, and then open parentheses. And inside of here we're going to enter our string. So say number types. Then we'll end our statement with a close parentheses and the semicolon. Now, just to clarify things were not technically using that convert to method. Where we're actually doing is accessing a class called convert that has multiple methods for converting from one data type to another. And because these methods start with a word too, for example, here we're using the two N32 method. I'm simply going to refer to it as the convert to method for simplicity. So just keep in mind that when I say that convert to method, I'm simply referring to a method of doing things, not the actual name of the method itself. And lastly, we will just want to print out the number to show that it worked. So you might say something like you are space on our number. They'll add an another Schengen, say, space years old. And then make sure you don't forget the plus symbols in between your different data types. Real quick, let's just go for code here from top to bottom. So first, we are asking the user to type in a number being that age. Then we have a string called number type, which is going to store the value that our console dot read line method returns, which is of the type string. Then I'm recruiting an nth column number that is going to store the integer value. That list method here returns or convert to a method, takes the string being number of tape and attempts to turn it into an integer value. Once that is done, it will return that integer value. And then we are storing it int number. Then we are printing out you are the number the user typed in, years old. Then we'll just run our program to make sure it works. Now this was only going to work if you type in an integer value and make sure there's no space, those are commas or anything like that. So it's going to ask how old we are. We'll type in a number, hit Enter, and then I will print out you are your age, years old, by the way, but you could use those convert to method to convert it to all sorts of different variable types. So for example, we could turn this into a double by saying convert to a double or a float by saying can route to single, and many others. When you're originally typing the method after you type in the word to, you can scroll down in this little drop-down menu and see all the different types that they have available. Keep in mind that if we were to change this type here, we would also have to change the type that we're storing in as well. Anyways, let's look for this video and the next video we are going to be doing the exact same thing, except we're going to be using the parse method and settled a convert to method. And we'll also talk about the differences. So what I'd like for you to do is save what we have here and we'll use it in the next video. Anyways, thanks for watching, and I'll see you in the next one. 18. Chapter 4 (User Input): Parse Method: In this video, we'll be collecting a number value from the user. Except this time we'll be using the parse method instead of the Convert to method. First things first, let's go ahead and just copy and paste all of this code we have up top here. Next, let's highlight our original code and comment it out. Remember you can do that by hitting this button here at the top. Then the only thing that we have to do differently here is change this method. So what we're going to change this to is 32 dot parse open parenthesis. Then we'll insert our string once again, followed by a closed parentheses and a semicolon at the end. Now where I'm getting this N32 from, as from this here. So if you mouse over your integer variable, you can see that it so System.out.print 32. And it represents a 32-bit signed integer, which is where this N32 comes from originally. Now if I were to change this to a float type, you can see that so System.out single and therefore, you just have to change this to single. Anyways, I'm gonna go ahead and undo that and run our program. As you can see, just like it did with it can hurt to method and asked how old we are. Once again, you'll need to insert a valid number and make sure there's no spaces are commas. Otherwise you will get an error and then hit Enter. It prints out our edge and said the string here. Now the difference between our parse method and our Convert to method, as that first string was equal to null, which we'll get into later on. Basically if our string was equal to null, it would essentially be the same as saying that our string wasn't referring to anything. And the difference being, is that if our number typed variable was equal to null or convert to method would return the number 0, whereas our parse method would return an error. So the main way to decide on what method to use is to determine what you would like to happen if the string were to be equal to null. Now I don't fully expect you to understand that now, let's, let's just something to keep in mind for the future. There is a method for determining whether or not your string is equal to null before using your parse method. The method for doing so is called the parse method. We will go over this method a little later on when we learn if statements. Anyways, that's it for this video. And the next video, we'll be going over some basic arithmetic in programming being addition, subtraction, multiplication, and division. So thanks for watching and I'll see you in the next one. 19. Chapter 5 (Operators): Basic Arithmetic: In this video, we'll be going over some basic arithmetic operators, being multiplication, division, addition, and subtraction. I have them all listed here at the top, followed by their symbols. So first thing we're gonna do is write some pseudocode. So we'll want to create two number of variables. Then we'll want to create a result variable. Then we want to do some math. And lastly, we're going to print out theories all. Let's create two integer variables. Will just come number one, number two, number equal to ten. And let's take a number equal to five. I don't just create an int and initialize it to 0. And go ahead and clean this up. Now at the bottom, let's just go ahead and go to console dot write line statement inside of our parentheses, we'll just insert the variable result. Then all we have to do and articulate the result of these two numbers being multiplied, divided, added, or subtracted together. And say result equals number one plus number two. And then a semicolon at the end. And then all we would have to do is change the symbol according to what we want to detail. So now if we run our program, we can see that it prints out 15. Now let's say I wanted to add five to number two here. But I would have to do is say number two. Number two again, Hive. And then let's go ahead and change where we're printing out here at the end to number two. And the reason we have to do that is because our assignment operator is going to take the result of everything on the right and assign it to a variable on the left. So basically, just now says that we wanna take five plus five, which is ten. So when we run our program, you can see that it will now print out ten. How do we forgotten to re-enter a variable name here? It just would have set number two equal to five. And just remember you can change this operator to whatever you wanted to be. Another thing you can do as a sign-up variable directly equal to another. And say number one, number two. Then if we remove this line above, number one would now be set equal to five. Then if we change the sign here and run our program, you can see that it prints out class. Anyways, let's go ahead and change this back tourism. And then in this line here, let's say result equals. And then one thing I wanted to know is that you can have as much math on the site as you weren't an l work just the same way it did as when you were taking math in school. So your president is going to be multiplication, division, addition, and subtraction. Anything in parentheses will happen first. So if we were to say in parentheses, one, flash number two, and then multiply this by five and put a semicolon at the end. We would now get the result of 15 times five. When we run our program. We can see that that's what happens. Anyways, I'd like her, I love you to go ahead and save the code that you have here, cuz we're gonna use it in the next video. And the next video we'll be going over the increment and decrement operators. So thanks for watching. I'll see you on the next one. 20. Chapter 5 (Operators): Increment & Decrement: In this video, we are going to be going over the increment and decrement operators, which are as follows. So your increment operator is two plus symbols and your decrement operator as two minus equals. What this is is basically an easier way of adding one or subtracting one from a variable. They made this possible just because of how often people add and subtract one from variables will be using these a lot, especially when we get into loops and going through collections. So for example, let's say we wanted to add one to our number one variable. All we would have to do is say number one and put a semicolon at the end. And now are number one is equal to 11. So this is the exact same as the method we used in the last video where we said, number one, number one plus1. Anyways, I go ahead and comment that I'll send down here and let's go ahead and change for us all to number one, just to show that it worked. And it will go ahead and run our program. And as you can see, it printed out 11. And if we were to change this to minus, minus or the decrement operator, you can see that it would print out nine. Ok. Now another thing I want to show you is that this operator can be used in different ways. And what I mean by that is this. So let's go ahead and delete this line of code. And we'll say result equals number one plus, plus and i semicolon. And then we're going to basically recreate this line except with a slave. So were gonna say result equals plus, plus, then number one. And then after each of these lines, what's go ahead and print out the result. I'm going to also comment out this line down here at the bottom. And then inside that both of these, let's just go ahead and add some text to make it more obvious which operation we did. So in here we'll add a string and we'll say number plus, plus colon space. We'll put in our quotation marks, and don't forget to add a plus symbol in between your string and your variable. And then we're gonna go ahead and do the same thing for down here. Then in between both of these, let's go ahead and set result back equal to 0. Now, the difference between these two lines as this. So I'm just gonna go ahead and add a comma here. Basically this one here at the top is going to set result equal to number one. Then it's going to add one to number one. While the bottom one here is going to add one to number one. Then it's going to cite result equal to number one. I'll so we're going to add one more line of code here after a result equals 0 and say number one equals ten. This way we have the completely fresh start between these two sections of code. So just sign here, and this one here will both add one to our number one variable. However, result is going to be different. And as because like I said, this one is going to first set result equal to number one, and then it's going to do the addition later. This is signified by the fact that our increment operator is after the variable. Well, this one is gonna do the addition first, and then it's gonna set result equal to the result of that. And once again, let us signify it by the increment operator being before it, the variable sum math first done the assignment, whereas this one was the assignment first than the map. So what's going to happen when we run our program, as a result is going to be set equal to ten. And then number one is going to equal 11. Then on our first line and will be printing out ten. Then we're going to set result back equal to 0 and number one back equal to ten. And then on a separate line, and it's going to print out the value 11. And as you can see when we run our program, that's what happens. That our number one variable was in fact incremented. Let's go ahead and print out number one after each of these as well. So I'll say console dot write line number one. And we'll just copy and paste that down below. As you can see, it printed 11 twice. Anyways, let's up for this video and the next video we're gonna go over them modulus operator. So thanks for watching, and I'll see you on the next one. 21. Chapter 5 (Operators): Modulus: In this video, we'll be going over the modulus operator, which as you can see is this lip percentage sign as the symbol. And what this does is return the remainder of dividing two numbers. So let's go ahead and start off with some pseudocode. First we're going to create two double variables. Latin woman, I create a result variable. W1 will wanna do some math. And lastly, we want to print out our result. So we'll start off by creating two doubles call number one and number two. Equal to 0 will create a double result variable. And then down here at the bottom, let's go ahead and print out our result. Then let's go ahead and number one. And lastly we'll say result equals number one, modulus number two, and a semicolon at the end. What this was going to do is take a number one being divided by number two being five. And then it's going to excite result equal to the remainder. If there is no remainder, result would equal 0. Then when we run our program, because six divided by five has a remainder of fun. That is what it's going to print out on a separate line. One way to find out if a number is odd or even is by using the modulus operator. So for example, if we wanted to know if number one was odd or even, we can say number one modulus and then two. And now if we had a remainder, we would know it was odd and if we didn't, we would know as even. Anyways, that's it for this video. And the next video we'll be going over assignment operators. So thanks for watching, and I'll see you in the next one. 22. Chapter 5 (Operators): Assignment: In this video, we'll be going over assignment operators. First, let us go ahead and create an integer. Call it number. And we'll go ahead and set that equal to tn. Now before if we wanted to do any kind of operation to our number variable, we would either use the increment or decrement operators, or we'd say some length is number equals number five, for example. Now the assignment operators basically make this operation much easier. So if we wanted to create this exact operation about, oh, we'd have to do essay number plus. And these two lines of code are exactly the same. So just to prove less, let's go ahead and in-between these lines, let's say number equals ten. Just send it back to the original value. And then below each one of these, let's go ahead and print out number. And then when we run our program, you'll see that it prints out twice. And one thing to know is that you could change this operator here to be any of the operators we've gone over in thus far. Anyways, let us up for this video. And the next video we're gonna talk about concatenation. So thanks for watching, and I'll see you in the next one. 23. Chapter 5 (Operators): Concatenation: In this video, we're gonna talk about concatenation, which is a way of combining multiple strings together. So first off, let's create a string variable. And we'll just call it string one. Then set it equal to Hello space, then will create another string called shrink to equal world. And lastly, and we'll create another string called combined shrinks. And we'll set x1 equal to a blank string. Now to concatenate string one, and we'll say combine shrink equals string one, shrinks. Then we'll go ahead and print out combining shrinks. And as you can see, that the two together and print to the console. We could even add a string n here without it being a veritable. So for example, we could, I'm an exclamation point. And if we run our program again, you can see that it has now added. We could've also used the addition assignment operator like so. We could have such string one, string tail, and then printed out string1. And as you can see that the exact same thing. And the next video we're gonna be talking about casting. So thanks for watching and I'll see you in the next one. 24. Chapter 5 (Operators): Casting: In this video, we're gonna talk about casting. So first let's start by creating two integer variables. And we'll say int num one equals five. And we'll say num two equals four. Then let's go ahead and create a flow called Herzl and set it equal to numb one plus num to us right now what we're doing is setting our float called result equal to the value of number one and number two, both being integers being added together. So in this operation we are converting an integer data type to a flow. Casting is when you turn one data type into another. And the reason this is okay, is because of float can hold an integer value with more precision. However, you can not do this the other way around. So because our float can hold any value that our integer Ken and more, it will implicitly casted over. So if we print out the result and run our programs, you can see that it'll print out nine. However, this wouldn't work the other way around. So if we were to, for example, change those to a byte, you can see that when we run our program, we get an error. And as you can see, this arrow says that you can not implicitly convert type ent to type by an explicit conversion exist. Are you missing I cast. Now anytime you're converting over to a type where you'll potentially lose information, you need to explicitly cast it. So what we have to do as explicitly turn the result of this operation into a bite. To do that, all we have to do as n parentheses, put the data type that we want. So in this case we put by it. And then because we are working with this whole operation, we need to also put this inside the parentheses. And now when we run our program and I'll print out nine. Keep in mind that the datatype byte can hold the value nine normally. However, because it holds less than the data type and it will not implicitly converted. Now these parentheses here, we're only necessary because we were working with an operation. How do you done something like this? Like say result equals num one. And then explicitly casted this tool. We would not have needed the extra set of parenthesis. So if I go ahead and comment out this line above and run our program, you can say that result was equal to numb one. Anyways, go ahead and save what you have because we are going to use it in the next video. And in the next video we're gonna talk about truncating. So thanks for watching, and I'll see you in the next one. 25. Chapter 5 (Operators): Truncating: In this video, we're gonna talk about truncating, which means to cut off the end or something. So to show you an example of this, let's go ahead and erase. So Sina code. Then much change num to overflow. And we'll set it equal to 4.5. And then don't hurry or F at the end. And lastly we'll say int result equals n1 plus n2. Then we'll explicitly cast this operation to an end. Now because an integer cannot hold the floating number, instead of this being equal to 9.5. That's just going to equal nine that us because it truncates everything after the decimal point. It does not round up or down, it just gets rid of it. And as you can see, when we run our program and print out the result, and it will simply print nine. Even if we were to change this to 4.9, we would still get the same answer. In the next video, we'll be talking about scope. Anyways, that's it for this video. So thanks for watching and I'll see you in the next one. 26. Chapter 6 (Conditionals): Scope: In this video, we are going to be talking about variable scope. So I have some notes here and in this episode you guys don't have to type anything. I just kinda wanna go over some stuff with you. So first off, variables must be made within a class. Thus far, we've been making all of our variables within our class program, which begins here at this open curly bracket, and then here at this close to him. And as you can see, Visual Studio add-in unless dotted line to show us that these two curly brackets are associated with one another. Next, there are three different levels of variable scope. You have class or object, method or function, and then block, leap or statement. These are just different names for the same thing. So class and object are the exact same thing and the name has just used interchangeably. Same goes for these ones as well. So if you were to declare a variable right here within our class, and it is now available anywhere below within the class. Now, variables declared within the class are called fields or a class members. And like I said, they can be accessed anywhere within after declaration. They can also be accessed outside of a class by using access modifiers, which we'll get into later. There are also available to any non-static method or function. Note that our main method as a static method, and we'll get into static and non-static later on. Next, if we were to declare a variable within a method, it would be available anywhere within the method after declaration. So it'd be available from this point onward until this closed curly bracket, which signifies the end of our method. These variables are normally called local variables. And like I said, they're accessible anywhere within the method after declaration. Also, Method variables cannot be declared twice, meaning you cannot have two with the same name. Now, the same does apply for class variables as well. However, you can have a class variable and a method variable. How does the exact same name? But within their individual scopes, they can not have the same name. Which is why you've seen me comment out certain lines of code that we've copied, because you can't declare two variables with the same exact name within a method. And they, you can't have two class variables with the same name. A class variable could share a variable name with one of its methods. Method variables also no longer exist as soon as the method is done executing. Meaning once we hit this close bracket here, any variables declared within the method no longer exist. Lastly, we'll go over variables declared at the or block level. We'll be going over loops and shortly. However, I just wanted to give you some insight as to how variables declared within a loop work. So once a variable is declared within a loop and it is now available anywhere below, these are normally called Looper statement variables and are only accessible anywhere within the loop. Meaning as soon as we hit this close bracket here, any variable we declared inside would no longer exist. Anyways, that's it for this video. And the next video we'll be going over exactly what conditional statements are. So thanks for watching and I'll see you in the next one. 27. Chapter 6 (Conditionals): Intro To Conditional Statements: Unless video we're gonna be talking about conditional statements. A conditional statement is a statement that checks per a certain condition and then flight condition that it will run a specified section of code. So just to give you an example of how this works, you'd have the condition and then normally some block of code. So as our main method was being executed, as soon as I came across this condition, it would check to see if it was true, if the condition was true, and it would run all over the code inside. However, if the condition was false, all this code would be skipped entirely and it would continue on down here. Anyways, this was just the basics of how a conditional statement works. So things you might want to do is check if a button is pressed. If a number equals a certain amount, if a string, so something specific, NFL player characters reloading if a certain event has taken place, make cetera. Anyways, that is it for this video. And the next video, we'll be talking about relational Andy, equality operators, which are used in a condition to check for various things. Anyways, thanks for watching and I'll see you in the next one. 28. Chapter 6 (Conditionals): Relational & Equality Operators: In this video, we'll be talking about relational and equality operators, which helped you to check for a certain conditions. So first off, we have the equality operator, which checks if t values of two operands are equal or not. If they are equal, that condition will become trail. The equality operator is two equal signs. So for example, if I had the number ten on both sides of the equality operator, the condition would be true. Next, we have an operator that's checks if two things are not equal to one another. This operator as an exclamation point and then an equal sign. So once again, for example, if we had the value ten on both sides. This is because in order for this condition to be true, these two things need to be. In another. Next, we have some more basic operators that you've probably seen before. And you have a greater than, which is just the greater than symbol. Less than, greater than or equal to. And then we have the less than or equal to. So in order for this one to be true, the value of the operand on the left has to be greater than the one on the right. The opposite can be said for the less than and what's the value of the operand on the left has to be less than the value of the operand on the right than the greater than or equal to. Check if the value of the operand on the left is either greater than or equal the value of the operand on the right, then it is the exact opposite for the less than or equal to. Write checks to see if the value of the operand on the left is less than or equal to the value of the operand and the right anyways, but does that for this. And the next video we're gonna talk about logical operators. So thanks for watching, and I'll see you in the next one. 29. Chapter 6 (Conditionals): Logical Operators: In this video, we're gonna be talking about some logical operators which helped you to check if certain conditions are true. So when working with conditional statements, you're gonna have something like this. In which the purpose of is to find out whether this condition is true or not. So it knows whether or not to run a specific section of code. The first logical operator we're gonna go over is the operator which checks to see if both operands are true. The operator for this as symbols. So for example, we could say if a is true and if b, then we want it to run a certain section of code. Next we have the or operator, which is two vertical lines. So for example, we can say if a or B is true, then we want to run a certain block. Okay? And lastly, we have the not operator, which he kinda saw in the last video, which checks to see if a condition is not true. The operator for this as an exclamation point and go for the condition. So it looks something like this. So if we had a bool called a and it was false, this condition would now be true because we wanted to check if that was not true. So if condition a were false, then we run this block of code because now are not true condition would be true. Anyways, that does it for this video. And the next video, we're gonna be going over f statements, which was our first conditional statement, which checks to see if a condition is true and then runs homeland block of code. Anyways, thanks for watching and I'll see you in the next one. 30. Chapter 6 (Conditionals): If Statements: Unless video we're going to be talking about if statements. The syntax for this is as follows. We would say if parentheses, and inside those parentheses would be our condition. And afterwards we wouldn't have that block of code that we run a run if her condition was met. So let's go ahead and try this out. First will create an integer variable called number and x i equal to ten. Then we'll say open parentheses. Number is equal. Remember the operator for that as T0 equals signs to ten. Then we want to run the following block of code. And then here we'll say console dot write line. And then inside of quotation marks will say condition was true. Now when we run our code and it should print out condition was true. And as you can see that that's exactly what it did. However, if we were to change our variable number to five, for example, it will now print out nothing. And this is because this condition would no longer have been met and therefore, this block of code would have been skipped entirely. Now you can see when we run our code and print out nothing. Now just to show you something that you can do for readability if you only have a single line of code that you want to run inside of an if statement. The curly brackets are technically unnecessary and your code can just look like those. Some people find this to be more readable. Feel free to use whichever you prefer. Also, we can swap this operator out with whatever we wanted. So we could say If number is greater than or equal to ten, for example. And now if we set this to ten, our code would run. If your condition was met. Once this block of code is done executing, and it will continue running code from here on out. So for example, if I were to say console dot write lines, end up if statement. You can see that that would be printed outright nothing. Anyway as I'm gonna go ahead and erase that. And I'd like for you to save the code that we have here because we're going to use it in the next video. And the next video, we're gonna be talking about nesting if statements. So thanks for watching and I'll see you in the next one. 31. Chapter 6 (Conditionals): Nesting If Statements: In this video, we're gonna be talking about nesting and if statements. The nested IF statement as an If statement inside of another if statement. To test this out, let's change the name of our number variable to number one. Now, one way to do this in Visual Studio would obviously be the genes, the name here and here. However, one thing Visual Studio allows you to do is to highlight the name, right-click on it. And then I have renamed. And now when we edit the name, it'll edit all instances out those names variable. So you can say number one. And as you can see, a change both of them and then just had applied. Then we'll create another variable called number ten. Well, I'll set this one equal to five. And our if statement condition, let's just say if number one is equal to ten, and then etc. Console dot write line. Let's have the word first before either the word condition. Then right below that, let's go ahead and create a new if statement and check if number two as equal to HIV. And we'll say console dot write line. And we'll say second condition was true. So now if number one is equal to ten, then this block of code will run. If this condition is false, then I will skip all the way to the end down here and continue reading code, meaning in which kept everything in here entirely, including this f statement. However, if this condition is true, so if number one is equal to ten, then it's going to run this line of code pressure. And then it's going to check if this condition is true. To determine whether or not I should run this block of code. If this condition were false, it's kept till the end of this and continue on to the next line. If it were true, then I'm going to read all of this code and then continue on. So if we were to run a program now, we can see that it would have print out both of these lines. If we were to put the not symbol before our second condition, and then put this whole thing inside the parentheses to avoid getting an error. Now, I would want to know if number two not equal to five because it wouldn't want those condition did not be true. So if we were to run our program now, only the first condition would have been that also you guys can have a much longer operation on this. So I could say if number one was equal to ten or if number one plus phi, for example, was equal to 20. Then let's go ahead and change number two to six. So now if we were to run our code, both of these would print out. However, if we were to change our number one variable to something like 13 and run our code only the second conditional would be true. However, it would not run because those conditions that would have been false. So therefore we would print out nothing. But if we were to change this to 15, when this condition ran, it would check to see if it was equal to ten, which it is not. But because we have the or operator here, but also check to see if this condition was true. And as long as one of these is true, our program would run. Now, I would take number one being 15 plus five, which is 20, and then see if 20 is equal to 20. And because of this condition would be true and thus would run as well. Because number two is not equal to five. And you could keep this going for as long as you wanted. You could even thrown an and operator and have another section of code similar to this one. And then just simply put these in parenthesis. Now, obviously in this case this machos, but if these were different era now check to make sure either one of these two is true because we have the source symbol here. And at least one of these would have to be true. Anyway is I'm gonna go ahead and undo that. Basically, you want to use f statements anytime you want to check if the condition is true. And then effort as you want to run a certain section of code. Anyways, that is it for this video. And the next video we'll be talking about if else statements. So thanks for watching and I'll see you in the next one. 32. Chapter 6 (Conditionals): If-Else Statements: In this video, we're going to talk about statements. So how they work as, as follows. Condition. Then you'd have a block of code that would run m psi conditional is true. Afterwards, you would say else. And then having another block of code to run EFSA condition was false. So for example, we could say any number higher than, let's say number is equal to five. We want to print out number is equal to five. Then we can say print out number was not equal to one. And then the lower if-else statement, let's print out and of f statement. So right now, if we were to run a program that would check if number is equal to five. Because let us trail, it's going to go ahead and run this code here. Now our else statement only runs if the if statement was false. So because in this case it would not be SAS code here would be skipped entirely, and then the rest of the code would be executed. So if we run a program and it's gonna say number is equal to HIV and the above statement. Now, if we were to change this to, let's say two, and run our program again. You can see that this block of code did not run. However, this one did. Because an else statement basically says, otherwise, I want to do this. The reason this is useful as because obviously in our case, if number was equal to five or if this condition was true, we would not also want to print out the number was not equal to five because that wouldn't make any sense. Also, one last thing I wanted to show you is the inside of an if statement. You can say if and then you can just type in false high in. So we can say f true. Run this block of code. Now, obviously this is always going to be true, and therefore this one always print. And we can also do the same by saying false. And now this code, and here, whenever, right? I just wanted to show you that this was possible. However, I doubt you will ever meet it. Anyways, that is up for this video. And the next video we're going to be talking about Else statements. So thanks for watching, and I'll see you in the next one. 33. Chapter 6 (Conditionals): Else-If Statements: In this video, we're gonna be talking about and if statements, which basically work as follows, where you'd say if a condition is true, run this block of code. Then we would say else. Another condition was true. We want to run this block of code. However, listen only runs if no previous condition work true. And lastly, you can put in an optional statement at the end, which only runs a block of code if none of the previous conditions were true. Making it a catchall. So for example, let's say count equals 30. Then we'll say Emma count is equal to 30. And we want to print out as last trend five. And we want to print out low. We can either here or we can even put another else. And we'll say if m is equal to 0, then we'll print out empty. And then like I said, you can have a catch-all statement here at the end, being an else statement to run anything in this block of code if all of these are false. Anyways, I'm gonna go ahead and remove them. Now at the bottom here, I'm going to print out and Novo statement. So how this else-if statement works, and let's see if ammo count is equal to 30. If it is, it is going to run this block of code and then it's going to skip to the end of her else-if statement and continue running. However, if this condition is false, then it's going to check if ammo count was less than five. If it is, it would run this block of code and then skip to the end. However, if this condition was false, then I would check this block of code. And if that were true, it would run the code within this block. Or if that was false, then I would run this. Just note that as soon as one as true, and it's only going to run that block of code amongst skip to the end. So if we were to run our code now, it's gonna see if AMA countless equal to 30. And right now ammo count is 30. So because 30 is equal to 30, so this condition will be true. And we're going to print out full. Then because our else statement here only checks for one condition to be true and we'll skip to the end and print out a statement. So let's go ahead and check that. Now as you can see, that's what happened. Now, what if we were to change this to something like 20? If we were to run our code all over, these would be false. And that's because our ammo count will not be equal to 30. It would not be less than five into it not be equal to 0. So all it's gonna do is print out endo statement. Now, if we wanted to catch something like time, we could add an another else-if statement and check if ammo count was greater than or equal to five to catch everything else. Or we could just simply create an else statement. And inside of here, we could print out none torture. Obviously, this isn't a great example of excuses, but I just wanted to show you that it's basically a catch-all. And now this will only run if all of these were false. Because we're basically saying if this condition a shoe run this, run this, etcetera, and then saying otherwise run length k. So if you ran and now I'm going to say none or true, and eventually anyway, so that's it for this video. In the next video, we're gonna be talking about switch statements. So thanks for watching, and I'll see you in the next one. 34. Chapter 6 (Conditionals): Switch Statements: In this video, we're going to be talking about switch statements. Now, there's a couple of differentials between also statements into a switch. So if you have more than three else condition checks and an else-if statement, and you are only checking for a specific value, then you'll want to use a switch. The syntax is as follows. The switch and then parentheses. You want an expression, then an open curly bracket. And then inside you wanna say case, run code. And then at the end of your section of code, you want to say break semicolon being can do this as many times as you'd like. Case phi u, one, run code break, case by U2, U3, etcetera. And then you'll have a closed curly bracket at the end. Now, optionally, you can enter a catch-all, which would have basically serve the same purpose as our else statement did and our MFLs and our else-if statements, we would say default colon, run code. Right? Okay, so let's go ahead and try this out. Let's create an income number and set it equal to five. Then we'll say switch. And inside parentheses will insert a number variable. And I'll go open and close curly bracket. And inside, let's say case one, colon, console dot write line. And let's just go ahead and insert our variable in here. And then we'll say break. Now if you want, you can answer all over this inside of open and close curly brackets like so. However the associate necessary. But you can do whatever is more readable for you. And then I'm gonna go ahead and create these. Then lastly, go had a default which remember is optional. Colon, console dot, write, line. And then I'm going to go ahead and print out none were true. And lastly, outside of this switch, switch. So remember you want to use a switch statement anytime you have three MR. elsif conditions, the check and an else-if statement, and you only need to check for a specific value. The reason I say that as you can not put any logic in here, so I cannot say case less than four, for example. Now when we run our program, that's going to go ahead and it's going to check number, and it's going to say f, it is equal to one. I want to run this. Otherwise it's going to check if it's equal to two and so on until it gets to here. And then it's going to go ahead and print that number being fine. Otherwise, if none of these were true, thus here would be printed out. Then it's also going to print out and dosage. I printed out five inside the endoscope. And example of why we might wanna do this is let's say we had a bunch of different dialogue options and the game. We could ask a question and then have multiple options, each equal to a different value. And we can say if option one was pegged, say this, or run this animation case to do this one. Thanks Sandra. Anyways, that's it for this video. And the next video we're gonna talk about the ternary slash conditional operator. So thanks for watching and I'll see you in the next one. 35. Chapter 6 (Conditionals): Ternary Operator: In this video, we'll be talking about the ternary or conditional operator, which the syntax for those homes. We basically wanna say condition, question mark, colon value if false. And then set this equal to something. So for example, let's create an end number equal to four. Then we'll create a bool called Less than five. Afterwards, we're gonna wanna say less than five. I'll say number less than five. Question mark, true, colon false. So now less than five is going to be set equal to trail. If this condition is true, or I'll be set equal to false. And with this condition is false. Now, this doesn't only work for a bulls to show those, let's create another integer called number two. Then let's say number two. Number less than question mark, colon. And then let's go ahead and print out less than five. And on a new line. Let's also print out number two. So I run a program, what's going to happen as our bull less than five is going to be equal to true or false. Depending on whether this condition is true or false, then our number two variable is going to be equal to 50 or a 100, depending on whether or not number is less than five. So it's going to happen when we run our program has less than five psi equal to true. And number two, there's going to be set equal to 50. So I run our program, we're going to be printing out true and then 50 on two separate lines. And let's go ahead and change our number five here TO three. So now when we run our program, that's going to say true and then 100. So basically you're saying, I want you to check this condition. Then based on whether it's true or false, I want you to set whatever's over here on the left there were assignment operator equal to one of these items. Anyways, that does it for this video. And the next video, we're gonna be going over the try parse method, which I said we'd be going over once we had learned if statements. Anyways, thanks for watching and I'll see you in the next one. 36. Chapter 6 (Conditionals): TryParse Method: In this video, we're gonna be going over the parse method. Most of the time when working with conditional statements, you're going to want to get some kind of user input. Personally, we're kinda wanna do is create a number variable. Then Bergen, I wanna get some user input. Then we'll set number equal to the input. So we're going to say int number. Let's just go ahead and set this equal to 0 for now. Then, let's say console dot write line type number. Then let's create a string called user input and SQL to console dot read line. Next we're going to say int tri-party. And then inside of parentheses we're going to insert our string being userInput comma out number. I'm going to semicolon at the end. Then down here, we're gonna say a number equals in dot parse userInput. Now, this isn't technically necessary because our tripe parse method is going to automatically parse user input into number if it returns true. However, we're gonna leave this here for some future examples in this video. However, we only wanna do this if this method up here was equal to true. So we're gonna say f worked. And because it, let's us live bool. This was just going to check if work is currently equal to true or false, which is going to depend on whether or not it was able to come in where our string user input into an integer and put it into number. So we're gonna say f worked is true. Then we want to go ahead and change number equal to n dot parse userInput. And lastly in southern risk statement, let's go ahead and print out numbers. So now when we run our program, it's gonna ask us for a number and a higher to insert 20, let's say and hit Enter. It's gonna go ahead and print out 20. Now we had done something similar to this in the past by just using our parse method, have R. By using the try parse method, we can now make sure that we're without causing any errors. Show to show you what I mean. Let's go ahead and comment that out and also comment how our if statement. Now when we run our program, if I were to insert something like 5x plus four and hit enter, how would immediately get an error? Because our input was not in the correct format. For same thing would happen if I were to try and insert letters. However, if I go ahead and uncomment, those are try parse method. And it's going to make sure that our input can in fact be converted into an integer and inserted into our number variable and f. So this will return a boolean value being true. If it did not work, it will return false. And it would still change the value of number. But because the conversion didn't work and it returned false, it is simply going to change it to 0. So if for whatever reason are try parse method returns, false. Number will be set equal to 0. If it returns true, then it's going to be set equal to whatever we typed in prey user input and takes us from the top. So for us we created an insert call number and set that equal to 0. Then we ask the user to type a number and then save that with a typed into a string called user input. And user input was saving any input tight until the Enter key was hit. Then you have a book called The Work, which saves the result of our try parse method, which checks to see if I can take this string and convert it into an integer and then NPA into or variable number. Then if that did work and our bull work was equal to true, then we want to have them parsed that by calibrating our user input string into an integer value and then setting our number variable equal to that light. Once again, remember that this was unnecessary because this was already done for us in the tripe parse method. If and when it returned trail. Wherever we have this here to kind of signify the tribe parsed methods use. And for another example, I have for you here using the parse method. And lastly, we went ahead and printed to the console. So just to show you what would happen if we were to type something else like we did before? Let's go ahead and run our program and type Hello. Now because this wasn't in your format, meaning we didn't type in an integer number. What happened was worked, was Landsat equal to false because this method returned false and this here and never ran. Then just to show you something. And let's go ahead and create a flow called number two and set that equal to 0. And then we'll do a float try parse. And then we need to make sure that we're changing what we're attempting to output a two to number two. As this now needs to accept the float. Then down here, we'll say float parse. And we'll explicitly convert this whole method and turn it. Now, I know we've explicitly turned floats into N2O4. I just wanted to show you that you could do the same thing with an entire method output. So let's go ahead and run our program and type something like 8.9. Now prints out eight. So because we type then a float value, our float dot try parse method, return true, which means that this code here ran. Then we took our input, convert it to a flow, and then converted that whole thing to an end. Now because an integer only holds whole numbers and truncated the 0.9 and just made it eight. Anyways, let's look for this video. And the next video, we're gonna be talking about loops. So thanks for watching, and I'll see you in the next one. 37. Chapter 7 (Loops): Intro To Loops: In this video, we're going to be talking about loops. Loops are a way to iterate through a section of code multiple times. The general syntax is as follows. You're gonna say while a condition is true, run this code. Now, I'm sure you can think of multiple reasons why you might want to use a loop, but I'm just gonna go over a few examples. You might want to print out a number a 100 times. Let's say you're making a shooting game and have the three round burst gun. You could have run three times. You might want to run some code continuously while a button being pressed. Now there are multiple types of loops that have their key differences. And you'll want to use whichever one is best for your situation. And you'll be learning about the different types in the upcoming videos. Anyways, in the next video, we're gonna be going over our very first loop, the while loop. So thanks for watching, and I'll see you in the next one. 38. Chapter 7 (Loops): While Loops: In this video, we're going to be talking about the while loop. The syntax for a while loop is as follows. You're gonna say while. In parenthesis, you put the condition that you want to check. And then you'll have the code that you want to run. So to test this out, let us go ahead and create an nth column number and set it equal to 0. Then let's say we wanted to print out the numbers 0 through ten. We could say, well, open parentheses, number is less than 11. Close parenthesis, opened and closed curly bracket. So the first thing you wanna do anytime you create a loop is get in the habit of making sure that this condition will eventually become false. Otherwise, this code is going to run indefinitely and crash your program. What you wanna do, but say number plus plus semicolon. So now that our numbers going to slowly increase every time this code is ran, I know that numbers eventually you're going to be greater or equal to 11, making this code false so that my program can continue forward above our number plus, plus. And I go ahead and print out number. And the reason I like to make sure that I'm gonna make this condition false before I do anything else is because if you forget this and you crash your program, let's say you didn't save and you just did an hour or two worth of work and your program crashes. Now what you're gonna have to do all that work again, he's like did just make sure I'm preventing that immediately. So now it's going to happen is when our program runs and it's gonna create an integer variable called number and set that equal to 0. Then it's gonna go to this while loop and it's going to check this condition. So it's gonna say is number less than 110, less than 11. Yup. So it's going to go ahead and print out 0. Then it's going to add one to a number. Now number equals one. Then once it reaches the end of my while loop, it's going to go ahead and check this condition all over again. So it's gonna say is one less than 11? Yep, go ahead and print out one. And we're going to add another one to number. And that number is two, is two less than 11, yup, all the way until it gets to 11, then it's gonna say as 11, less than 11. No. And then it's gonna continue forward. So I'm gonna go ahead and print out and wildlife. So whenever you run our program, it should print out 0 through ten. And then it's going to say and the while loop. The reason this happens is because once it sees that this condition is true and begins running our loop, it's going to continue running with this loop until this condition is false. So let's go ahead and run our program. Make sure we're now, as you can see, it printed out 012345678910. And early. And just like an if statement, you can put whatever kind of operations you want inside of here. And it's just going to check if it's true. And if not, this code just isn't going to run. So let's go ahead and start this at 11 and run our program. As you can see, it just printed out and a wildly. Anyways, that is it for this video. And the next video, we're going to be going over a do-while loop. Now what I'd like for you to do is go ahead and save this code, bec