 Hey guys, Crypto Grounds here. Welcome back to another C Sharp Crash Course video. This is episode 10 and today we'll be about operators. Don't forget to leave a like if you enjoyed the video, subscribe to my video and turn on notifications and click on the icon right here. It should be the icon and you can check out my other playlist if you're interested and let's get on with it. So today I'm going to be talking about all the basic operators. Okay. So first let's start out with the obvious. We have plus, minus, multiply, divide. Okay. Those are the basic math related ones. Okay. So I'm pretty sure you've seen these before, right? Okay. So if you want to set a variable, let's say a, we could set a equal to five plus five minus six. Now that'll be four, right? All right. You want to have an equal sign, right? But a would be four. So that's pretty obvious. I don't think I really need to explain how these operators work. Okay. Okay. So a thing to be aware with these is that their order of operations is kind of weird compared to math. So with these, the normal plus and minus, it goes from left to right. While if we have five times five divided by six, it goes from right to left. Okay. So that's why sometimes you might have to use parentheses. And if you're sure, if you're not sure about where to put parentheses, just put them there. And your average IDE should, well, these Visual Studio community does, it should tell you if these are useless parentheses or not. Okay. I still get very confused with the order operations. So I always have to use tons of parentheses till I get it right. So that's something I can't remember. So if you struggle with that, no, all right, I'm on the same boat. All right. Next up, we have, so right here, you got plus equals minus equals, you have times equals and divided equal. So basically, this just adds on to the variable you're changing. So if you do plus equals five, it will just add on five to that. And this is the same thing as a equals a plus five, just much shorter, just like that. Same thing for these three. Okay. Okay. And we also have this is really good for integers, or just adding one to a variable, but we have plus plus, we have minus minus. So this just adds one, and this one subtracts one. Okay. Instead of having to do a plus equals one, you can just do a plus plus. Next up, we have some things that I'm just going to point out. So we have equality operators. So we have also, actually, something I forgot, we have positive and negative. So if we set eight equals to five, because that we can add the plus sign, so it's positive. So if it's a negative five, it'll just make it positive. Or if we do negative five, it'll be negative five, right? And same thing for plus negative five, it'll just make it five. Okay. So we have some equality operators, I'm going to explain. So by default, if we have an if statement, which I'm going to explain later on in the series, let's say we have some bull. Now a bull can either be true or false, because it's a binary, it's a binary variable. So it's either one or zero, one being true, zero being false. Okay. So now the interesting thing, these are actually operators too. So if you've probably seen this before in some videos, but if you do while true, that's bad. So if you do while, not whites, but while true, now you have a number ending loop. Okay. Unless you break out of it. But this is a never because this is an operator. Okay. So this is true. This will always be true unless you break out of it. Okay. And those are kind of dangerous when it comes to user interface that will just completely freeze the system. Highly do not want you to really advise us to do that. Okay. All right. So unless you have an exit method or something. But anyways, it would still lag, right? Okay, so now if you do if bull, if this bull is true, it will run the code below. Again, I'll get more into this later on. So now you can add an exclamation mark beforehand to make a false. So if the bulls false, because this is basically just the opposite. Okay, it's the same thing with equals equals. So if we have a is equal to five, which is the double equal sign, then this is true. This is true. Or you don't write this, but this would be true. Okay. If this was four, this would be false because four does not equal five. So talking about the exclamation mark, equal sign is pretty much the same. It's pretty much the same thing as the other except the opposite. So if a is anything but five, then it'll be true. So let's say it's five, it will be false. If it was four or three, then it would be true like that. Now that's supposed to be a t in a t. So I'm gonna let's see. Okay, we still got more equality operators. So we have greater than, less than, greater equal then, or less than or equal then. Okay. That's pretty self-explanatory. If this was six, then this is false, right? If it was four, it'd be true. If it was five, it'd be true as well because of the equal. All right. Hope that makes sense. Okay. So now I'm going to talk about properly using some stuff like parentheses, stuff like this. So let's say we call a method and a nested method. In here, we would just do a method, parentheses, and then a nested method. Oh, see, I already forgot. And then we got to put our two parentheses here and then a semicolon. Yes. So this is a semicolon. This is a parentheses. I'm pretty sure you know that by now. But the point I'm trying to make here is that some people in my idle game tutorials, they completely forget about the parentheses. They kind of just copy down my code and they don't realize what the point of these parentheses are. So rule of thumb, always make sure you have equal amounts of left parentheses and right parentheses and you'll be safe. Okay. So that's just a rule of thumb. Okay. parentheses are used in methods such as this or if statements while statements, switch, stuff like that, or simply just math related things you want to group things together, right? That is the purpose of those. So let's say you want to do a a is an int, but let's just do this for example. Or actually, let's make this a double. Sorry about that, brother interrupted. But let's make a finally a double. Okay. So here, let's say we want to do five plus five for some reason, divided by two, this will become five, obviously. I mean, that's a really pointless calculation in general, but let's just say you have two variables adding up and you want to divide by another variable. So this would be the proper use of this parentheses, because you're grouping these together, right? Since divided goes right to left, it will divide these two first. Alright, so we have this, I just checked that. Yeah, that's right. We've want to group these two together, since this goes from right to left. So now, let's say we want to do five plus divide by two. Now, first on people, this may look obvious, it's just going to divide first order of operations, right? But if you do put parentheses here, it'll code the it'll work the exact same way. However, VS or whatever writer will say, these are redundant parentheses, you can get rid of those because this is the same thing as five plus five divided by two, right? Like that. Alright. Cool. Hopefully that makes sense. So now we have some other operators are not really operators, but symbols that you should probably get used to. But we have the curly brace used in every single method if statements, it's used to encapsulate the inner code. Okay. So if we add an if statements, if we have to add our curly brace right here. Okay. But the thing is, don't get confused with this, we can do if for example, and we can just do a one line of code like a equals five, and nothing else, we can do this. But just know if you'd have a plus plus under this, this is going to run even if this is false because this is not encapsulated. And how do we do that? You just add the curly brace like that. And now it'll only add another one if this is called, right? So if an L statements can get a little confusing, right? So you can have a nested if statements, if bull to you can also have else, which and then you can have like a one line of code right here, and then have else bull three or now it's just else, you have else, and then another one line of code, and then have else here. Okay. Okay. If this else wasn't here, sometimes your code would get confused. So here, let's get rid of this else down here. So let's say we have that one line of code, and we put else right here. Okay. So the problem with this is that sometimes it would confused right here, it would think this else belongs to this because it's under this one line, right? So how do you fix that? You encapsulate your code like this. So then it should look like this instead, encapsulate that else do this, that is the proper format for doing that. Otherwise, you can do one line stuff like this, if you're not doing it like that. Okay. Or if you don't have anything like this inside, you just have a one line of code doing something here, you could do else, if bull now the line or else here, like that. Okay. So you have if else, if else. Okay. And once it runs this right here, once this it runs this line, it will no longer check for these. Okay. So there's a difference between having if bull, and then if, so let's make this two, if bull, two, it will check for both of these in your method. Well, here it'll only check for the first one. If this is false, then we'll check for this one, and then this one, right? Okay, hope that makes sense. Okay. So we talked about those. Now we have our brackets. Okay, this is used for primary for arrays, right? I mean, I can't really think of another method or another way of using those right now. So if you have, and you wanted to clear new int, you just do new int, and then the size, like that, same way for accessing it. And array the curly braces at index zero, for example, set it equal to four, I don't know, whatever. That's pretty much the only way I can think of using that for now. Okay, pretty self exploratory. Now this one right here, it's an arrow. It looks like a, it looks like greater than or equal then, but it's not. This is basically permanently setting when this is basically just setting a permanent access access point, I guess, or like a definition for this, we're basically defining what a formula is. Okay, because we can make this a constant. But at that point, if we want this to always be five, then why not do public const for constants, you cannot change this const float. And same thing here and set it equal to five, right? That would be this, okay. However, if you want to set this to make it like an equation, let's say we want a formula to always be a times five. Okay, so if a changes, this will change to on the next axis, right? When I mean access, I'm talking about like, if you do console that right line, a formula, it will print out a times five. Okay, which would be if we set eight or four, that would be 20. I believe that is it. Okay. If you enjoyed this video, make sure you leave a like comment down below suggestions for this video, and subscribe to my channel if you're new turn on the bell for notification, and also check out my other videos in this top corner. Anyways, thank you very much for watching. Peace.