hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to show you all everything you need to know to get started writing code in c-sharp so sit back relax and enjoy the show if you wouldn't mind please like comment and subscribe one like equals one prayer for the youtube algorithm i'm gonna tell you why you need to learn c sharp c sharp is a very flexible language we can use c sharp for all sorts of things console apps web services games and if you're an aspiring game developer c-sharp is definitely a language you want to learn along with c plus but why not learn both and the average salary for a c-sharp developer if you have some experience is 63 000 per year according to glassdoor if that all sounds good let's begin to code with c-sharp we'll need an ide that's an integrated development environment think of it as software that helps us write other software one that i would recommend is visual studio community so you can just google that then head to this url at the top here okay then we are going to download visual studio and just follow the installation procedures so let's open this and run it so continue and here we have a bunch of different packages that we can download you'll want to check dot net desktop development for using c sharp and if you're interested in using unity you might as well just download this package too then we are going to install you have the option to sign in but i'm just going to click not now maybe later you can also pick a color theme for your ide i'm going to go with dark because i like to feel like a pretend elite hacker then start visual studio now with this home screen we'll continue without code i'll show you all how we can create a new project all right now to create a new project we'll go to file new project select c sharp console application next we'll need a name for this project i'll call this my first program next then create all right now this font size is very small you can either zoom in here or down at the bottom or you can change the font as well as the font size by going to tools options environment fonts and colors and you can change the size here what about 18 and we should be good and here we have a small program that was created for us automatically all this does is display some output the words hello world to compile and run a program you just have to click this green play button at the top and this will create a console window that displays our output of hello world whatever we have written here within quotes and this line of code is known as the main method it's the entry point for where our program begins and this set of curly braces after the main method is the body of the main method so our program will begin by executing any code at the top of the main method and it will work its way down and execute any subsequent code that follows so this main method is made up of a bunch of words that we don't quite understand yet static void main string args in time we'll learn what each of these words mean but that's more of an advanced topic so a textbook that i read once said to think of the main method as like a magical spell or incantation that we have to say in order for our program to run so let's see what happens if i remove the main method i'll still keep this line though console.writeline hello world and let's try it okay so it looks like there were build errors so we cannot run the program as it is now so we do need that main method and if you are missing it you can just type it in and it should work now now this is a standard writeline method whatever text that we put within quotes will appear within our console window to display as output so let's actually change it right now it says hello world but let's type something else so make sure that this is within double quotes let's change this to i like pizza and then run this again so now my output should say i like pizza and then you can add a second line of output just by writing console.writeline then within parentheses and within double quotes you can write something else like it's really good and now we have two lines of output i like pizza it's really good so to write output to the console window you type console.writeline then within quotes some text that you want to write one thing that you may want to change is the font and the font size of your console window because right now it's very difficult for me to read so to change that right click in the top left corner go to properties then go to font let's increase this to maybe 28 you can pick a new font style as well i'll keep it the same then you can also change the color scheme too i'll change the screen text to maybe green then okay all right but now this window is huge so let's change that so again go to the top left corner go to properties then go to layout let's change the width to what about i don't know 50 and the height to let's say 15 i think that should be good okay yeah that's not too bad and here it's actually a lot easier to read i like pizza it's really good oh one last stupid thing that i wanted to show you all is how we can make our console beep type console dot beep parentheses semicolon so then our program is going to beep when it reaches the end it's not really important at all i just thought it would be something fun to throw in at the end of this video so that's how to make your console beep for some reason all right well that's the very basics of c sharp to get you started in the next video we'll cover more on output and comments so i'll post this code to the comment section down below and well that's the very basics to get you started in c-sharp hey you yeah i'm talking to you if you learned something new then help me help you in three easy steps by smashing that like button drop a comment down below and subscribe if you'd like to become a fellow bro [Music] hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to show you all a few different ways in which we can format output in c sharp so sit back relax and enjoy the show if you find this video helpful please remember to like comment and subscribe your support will help keep this channel running all right everybody here's a few different ways in which we can format output in c sharp as we covered in the last video to display something to our console window we would type console.writeline then you need a set of parenthesis then a semicolon at the end you place your message within the parenthesis this is known as a method and we have a semicolon at the end the semicolon is kind of like the period at the end of a sentence when we finish a statement in programming we end it with a semicolon so to display a message within double quotes you would type something so this is known as a string literal we're literally printing something to our console so we kind of covered this in the last video this will display the word hello now there's another way in which we can display output that is just right console dot right parentheses semicolon and within quotes let's display something else what about hey now let's take a look at the difference between the two all right we have hey immediately followed by hello all in the same line in the last video we used two right line statements each string literal had their very own line but in this case it's all one line so with writeline after you finish your string literal it's going to hit enter like we're hitting the enter key and we'll move down to a new line right doesn't do that so you have two different ways in which you can display output to the console window right and right line write does not hit the enter key after the end it doesn't create a new line and rightline does so you can use either one depending on what you need now there is a shortcut to create a rightline statement you type c then hit tab twice and that will auto generate a right light statement for you okay so the next topic to cover is comments we can add a comment to our code and this will not be displayed as output so to write a comment within your code you need two forward slashes and you can see that the color of our text changed to green so i'm going to tell you this is a comment and this has no effect on our output this comment will not be seen all we see here is hey and hello you can also write a multi-line comment you would type forward slash asterisk this is a multi-line comment then to end a multi-line comment you would end it with asterisk then forward slash again and last but not least we have escape sequences we can add an escape sequence to a string to format our output so let's create a writeline statement and type whatever your name is okay now to create an escape sequence we need to add a backslash followed by a certain character depending on what character you select it's going to have a special effect on your string so if i typed backslash t that will add a tab escape sequence before displaying my name all right so we have a tab before my string so let's change this to maybe a backspace i'll add that here so backslash b that will add a backspace and my name is now br code alright so we can also do newline and for new line so my first name is on one line and my last name is on a second line now you may have noticed that there's all this garbage at the end of my console window when my program is done running so one way in which we can hide that at the end of our program type console.read key so basically this will prevent our program from ending until we type a key and it should be hidden now so if i hit the enter key well then my program is going to finish running all right everybody so those are a few ways in which we can format output in c sharp if you can give this video a thumbs up drop a random comment down below and well those are a few ways to format output in c sharp hey what's going on everybody it's bro hope you're doing well and in this video i'm going to explain variables in c sharp so sit back relax and enjoy the show do you all remember back in middle school when we learned about algebra we had to solve an equation to find the value of x and x as some representation of a number well with programming we can create our own variables but we are not limited to just numbers we can store characters words and even these things called booleans which are either true or false so i'm going to show you all how we can create our own variables in c sharp creating a variable takes two steps declaration and initialization to create a variable we first have to declare what type of data we'll be storing if we need to store a number we'll type int short for integer and we'll need a unique name for this specific variable so let's just call this x and then end the statement with a semicolon because with programming semicolons are kind of like periods when you finish a sentence okay so this step was declaration and i'll just add a note here so this step is declaration and now to assign a value we will initialize this variable so to assign this variable x a value type x equals and then some value let's say one two three then semicolon okay so we now have a variable named x and this step is initialization now you can combine these two steps so to do that we would say and let's say y this time equals three two one semicolon so we have two variables x and y so this step right here is both declaration and initialization now these variables behave as the value that they contain so let's display some of these so within a console.writeline statement i'm going to display x and then with a second rightline statement i will display y so console.rightline y and we have one two three three two one now you can use these for like math two we could say like int z equals x plus y and then display whatever z is console.writeline z and the result is 444. so these names for these variables really aren't descriptive x y and z we can give some more unique names that describe what kind of value that these variables contain so let's say int edge and i'll assign this variable age a value of 21 and then i can display my edge within a writeline statement or use it for something so let's say console.writeline and then i can display a message along with my age so let's say your age is so this part is within quotes to display the value of my age i will add plus edge make sure age is not within quotes because then we're printing a string literal and not the value contained within edge so this should display your age is 21. so there's more data types than just int this time let's use a double a double is really just a decimal number it's like a floating point number but with more precision there are floats in c sharp but i don't really think they're that important for beginners so with a double we can store a decimal number and int only stores a hole integer so if i try to display like 21.5 and then display it this is what happens so we'll run into a build error so with int we can only store whole integers but with a double we can store something that includes a decimal so let's say we have a double height and i'll assign this a perfectly average height of 300.5 centimeters i guess and now since this variable is initialized we can use it for something we can change the value or we can use it within a message so let's use console.writeline and i'll display my height within some sort of message let's say your height is space plus height plus another string let's say cm 4 centimeters then let's try it okay your age is 21 your height is 300.5 centimeters so a double variable can store a decimal number unlike with integers they only store whole numbers now the next data type is boolean and to declare a boolean variable we type bool then a variable name so booleans can only store true or false so this might be good if you need something that only has like two options like a light switch it's on or it's off if somebody's online that could be true if they're offline that's false or maybe somebody is alive let's say bull alive either true or false but the last time i checked i am alive so i'm going to say that is true and then we can use this boolean variable for something so let's use this within a console.writeline statement console.writeline and what should we say are you alive plus alive are you alive that is true so if i change this to false this would display are you alive that is false so that is a boolean variable it's only true or false so for practice i'll encourage you to try and type something besides true or false like the word pizza we can't shove a whole pizza into a boolean variable it can only be true or false so let's change that back okay the next data type is chart it's a character a single character what about symbol char symbol and we need to place this within single quotes so let's say our character is the at sign and then let's display it console.writeline your symbol is plus symbol your symbol is at sign so make sure that this is within single quotes when you assign a value so with chars we can only assign a single character if i attempted to add like a different symbol too well this wouldn't work then see we're getting an error here so that's where strings come in with a string we can store a series of characters and to declare this we type string with a capital s string let's say name string name and this value is within double quotes so type whatever your first name is and then we can use our name for something let's display a message that says hello whatever your name is console.writeline hello plus name okay hello bro your age is 21 your height is 300.5 centimeters are you alive false your symbol is at sign let's say that we have a username and i'll say string username equals symbol plus name and then i'll display this console.writeline your user name is colon space quotes plus user name whatever you typed here okay your username is at bro those are variables they're containers for values but you can store more than just numbers you can store boolean values characters and strings and a string is a series of characters so if you would like a copy of this code i will post this to the comment section down below and well those are variables in c sharp okay it looks like we're on constants constants are immutable values which are known at compile time and do not change for the life of a program let's say that we have a double variable named pi and this equals the first few digits of pi 3.14159 if this is not a constant people can actually change the value contained within this variable and that could be a security concern let's say pi now equals 420 and then i will display the value contained within pi so if you do not want people to be able to change this value we can precede the data type of this variable with the const keyword and this variable is now a constant and we can't update this variable now that it's a constant so yeah that's a constant it's an immutable value which is known at compile time and does not change for the life of the program and it adds a little bit of security to our programs because people cannot later change these values so yeah those are constants in c sharp oh yeah typecasting typecasting is the ability to convert a value to a different data type it's useful when we accept user input because when the user types in something it's going to be a string and strings can only do so many things and different data types can perform different things so it may be necessary to convert from one data type to another like for example we can't use strings for any sort of math we would need to convert a string to an integer or double to be able to use a string representation of a number so let's begin let's say we would like to convert a double to an integer let's create a double variable named a and i'll assign this a value of 3.1 for the first few digits of pi so what we could do if we wanted to convert this number to an end we could store this within a separate variable let's say int b equals now to convert this value to an integer we can use the convert classes 2 and 32 method so convert dot 2 into 32 parentheses semicolon and within the parentheses i'm going to place what i want to convert i'm going to convert the value stored with an a and then assign it to variable b and then let's display this variable with a rightline statement so console.writeline and then i will display whatever b is then let's try it and the value stored within a b is three so if we convert a double to an integer it's going to truncate any decimal portion if there is any so since we wrote this program this way it's not going to get rid of the value within a so if i were to display a it's going to be 3.14 all we did is that we took the value stored with an a and created a copy of it then converted it to an integer and stored it within b it's also possible to display the data type of whatever variable that we're working with so after a within our rightline method type dot get type then add a set of parenthesis this is the get type method so this will display instead of the value stored within a it's going to display the data type of whatever a is so the data type of a is currently a double now let's change this to b b dot get type and our variable b is an integer into 32 so if you need the data type of a variable follow that variable with dot get type then a set of parentheses this is a built-in method of variables let's convert an into double this time let's create int c equals what about 1 2 3 and we'll create double d equals convert dot to double then parenthesis semicolon within the parentheses we will convert c so place that within there and within a writeline statement we will display whatever d is console.writeline d so if your double doesn't contain like a decimal portion it's not going to display like point zero but if i were to add like 0.1 to the end of this then it will display a decimal portion so 123.1 and the data type of d let's follow this with the get type method so the data type of d is in fact a double okay now let's convert an integer to a string we'll need int what about e e equals three two one and i'll create string f equals convert dot to string are you beginning to see a pattern here then parenthesis semicolon then pass in e so place that within the parenthesis and we will display whatever f is console.writeline the value stored within f and that will be three two one so a string we can't use for any arithmetic but with ins and doubles we can so if we convert an integer to a string we can no longer use this for any math but if we converted a string to an integer then we can use it for any sort of math so let's follow this with get type method f dot get type and the data type of f is in fact a string okay exercise number three let's convert a string to hr hr is just a single character string g equals so a string is always within double quotes what about the dollar sign and a char is always within single quotes we treat strings and chars differently you can store a single character within a string however strings are different from chars there's different things that we can do so let's say char what comes after g e f g h char h equals convert dot to char then of course parenthesis semicolon within the parentheses we will place g and then display whatever h is so console.writeline h so h will still be a dollar sign but we treat it different because it's a character there's different things that we can do then let's get the type of whatever h is and h is hr a single character okay last but not least let's convert a string to a boolean string i equals true within double quotes so this is different from true without double quotes because this is a boolean and right now we're getting an error so represents a boolean true or false a string is always within double quotes so we would treat this string different from this boolean even though they say the same thing okay then let's convert this string to a boolean type bool not cool bull j equals convert dot to boolean parentheses semicolon pass in i then we will display whatever j is console.writeline j and this will display true then let's get the type of this variable so j dot get type method and the data type of j is a boolean now all right everybody so that's how to type cast we can convert a value to a different data type and it's really useful when we accept user input because it's always going to be a string and there's different things that we can do with different data types so it may be necessary to convert from one data type to another so if you would like a copy of all this code i will post this to the comment section down below and well that's typecasting in c sharp hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to show you all how we can accept some user input in c sharp so sit back relax and enjoy the show all right here's how we can accept some user input now when we do accept user input it's of the string data type so let's create a variable to hold and store our input let's create a variable named name and we will ask the user for what their name is now to read some user input type console.readline then parentheses semicolon so when the user types in something then hits enter we will take that user input and store it within this variable name which we can then use for something so within a writeline statement let's use the user's name for something hello plus name and let's take a look okay now to enter in some user input we'll have to type this into the console directly however it is good practice to let the user know what we want them to type in exactly because how's the views are supposed to know that they're supposed to type in their name right here so what we'll do is preceding our readline statement let's create a prompt to tell the user what we want them to type in so within a rightline statement let's say what's your name and then try this again okay what's your name now the user knows that they have to type in their name so type in your first name hit enter hello whatever your first name is okay this time let's accept a user's age and then we'll typecast the user's age into an integer variable so let's copy what we have paste it console.writeline what's your edge and we'll create a new variable of the int data type named age now we'll need to cast this user input into an integer so to do that we would type convert dot 2 and 32 parenthesis semicolon now take this statement without the semicolon cut it and then paste it within the parentheses so what we're doing is accepting some user input then converting it to an integer that we're storing within this variable edge and then we will display the user's age console.writeline u r plus age plus years old then let's run this again so our program is actually going to wait at each prompt until the user types something in so what's your name bro let's say that i'm 21 i'll hit enter hello bro you are 21 years old now one issue that you may run into is if the user types in something that's non-numeric and we try and convert it so let's try this again what's your name bro and instead of an age what if i type in a word like pizza this will cause an exception an exception will interrupt our program and this specific exception is a format exception input string was not in a correct format so there will be a future video on handling exceptions which will prevent the program from pausing and being interrupted but that's a future video in the meantime we'll just have to be sure that we're entering in the correct user input well okay then everybody that's how to accept some user input in c sharp i will post this code to the comment section down below and well yeah that's how to accept user input in c sharp hey everyone we're going to cover some basic arithmetic in c sharp so sit back relax and enjoy the show everyone i thought we could just cover some basic arithmetic real quick let's say we have a variable friends and i will assign this a value of what about five and within a writeline statement i will display the value stored within friends so of course friends will have a value of five but what if i need to update this like increment it i could say friends equals friends and we make a friend so we could say friends equals friends plus one because remember the value stored within friends is five this is no different from saying friends equals five plus one which would be six so let me display the value stored within friends and of course that's six of course you can change this to a different number too you could say friends equals friends plus two then the amount of friends that we have is seven so there is a shortcut of writing this too because this can be somewhat tedious what you could say is friends plus equals then the amount that you want to increment this variable by so if i need to increment friends by two i could say friends plus equals two and that would do the same thing that's like a shortcut so of course that would be seven so there's a third way to increment and decrement two this method is found within loops you could say friends plus plus however this will only increment a variable by one so if friends is initially five then we say plus plus well then friends will equal six so there's three different ways to increment a variable this way is found within loops this is the standard way and that's kind of the shortcut this line right here okay so let's decrement friends so we could say friends equals friends minus one or we could say friends minus equals one or friends minus minus so if we combine all these the amount of friends that we have is two let's work on some multiplication if we need to double the amount of friends that we have we would say friends equals friends times we use an asterisk for multiplication and programming times two then the amount of friends that we have is 10 and the shortcut would be friends asterisk equals 2 and that would do the same thing now division let's say that steve breaks up our group of friends so we could say friends equals friends divided by two and for division we use a forward slash now pay attention to this our current number of friends is five but what if we divide this by two well you would think that we get 2.5 right well you're wrong we end up with 2. that's because friends is an integer we can only store whole numbers we can't store that decimal portion that 0.5 so if this was a double well then that would be 2.5 so that's referred to as integer division and that's something you have to look out for so if friends equals friends divided by 2 well then the shortcut would be friends forward slash equals 2 and that would do the same thing and then remember i'm storing this within an integer so we will truncate that decimal portion and we end up with 2. and our last operator for this topic is the modulus also known as the remainder operator now for this example i'm going to change the amount of friends that we have to 10 so we can find the remainder of any division but i'm going to store this within a new variable int remainder and to find the remainder we could say friends then modulus which is represented by a percent sign than 3 so 10 divided by 3 will have a remainder and we will store that remainder within a new variable so let's pretend that we have a total of ten people and we have to break up into groups of three so there's going to be one person remaining and i will just display that remainder of one but if this was in groups of two so friends modulus two well ten divides by two evenly so there will be no remainder and the value will be zero so if you need to find the remainder you can always use this modulus the remainder operator and it's also pretty good for finding if numbers are even or odd too so that's always a plus as well alright everybody so that is some basic arithmetic i will post this code to the comment section down below and well that's some basic arithmetic in c sharp hey everyone in this video i'm going to show you all a few useful methods of the math class so sit back relax and enjoy the show alright everybody so here's a few useful methods of the math class that you might be interested in let's begin with creating a double variable named x and i'll assign a value of three now the first useful method is the pow method that will raise a value to a certain power and we'll store this within a new variable let's say a double a equals then to access the math class type math with a capital m dot and here's a whole bunch of methods they have access to so we are looking for the pow method right here then add a set of parentheses semicolon now within the parentheses the first value is your base so the base will be x and that is three and what power do we want to raise x to let's raise x to the second power and then display whatever our result is a so within the right line statement i'm going to display a so here is the result 3 to the power of 2 is drum roll please 9. so if we need 3 to the power of 3 that would be you know x whatever you're working with that's the base comma 3. so 3 to the power of 3 is 27. okay let's try square root i'll turn this line into a comment and we'll create double b equals then again to access methods from the math class type math with a capital m dot and we are looking for square root that is all the way down here s q r t parenthesis semicolon within the parentheses we will find the square root of x and then store it within b console.write line b and that would be 1.73 something something something something so that is the square root method let's move on let's create a double c and we'll find the absolute value of x so math dot a b s so the absolute value is how far away something is from zero so if you have a negative number like negative three well it's going to turn that into a positive number so the absolute value of negative 3 oh we need to display c so the absolute value of negative 3 is in fact 3 so that is the absolute value method let's move on rounding so double let's see we're on d equals math.round and we can round a number pay attention to the capitalization too okay now let's change x to 3.14 and then we will round x so place that within the parentheses of the round method and we will display d and 3.14 rounded is 3. now you can always round a number up by using the ceiling method let's create double e equals math.ceiling all right then we will place x within this method and display e so 3.14 rounded up using the ceiling method is 4. alternatively there is a floor method that will always round down and i'm just going to copy this so double f math dot floor and let's change this to 3.99 and display f so 3.99 rounded down is three okay now we'll need two variables for this next example so let's create double y equals what about five okay so we have the max method we can find the maximum value of two values or variables so double g equals math.max and within the parentheses we want to compare x and y and separate each of these with a comma so this will find the max between x and y and store the maximum number within g and then we should display g so the maximum between x and y is y and that contains five then we have min so double h math.min console.writeline h so the minimum between x and y is x 3.99 all right everybody so those are a few useful methods of the math class i will post this code to the comments section down below and well yeah those are a few useful methods of the math class hey what's going on everybody it's bro hope you're doing well and in this video i'm going to explain how we can generate some random numbers in c sharp so sit back relax and enjoy the show all right people here's how to generate some random numbers just so you know these are not true random numbers but rather pseudo random numbers and they're fairly darn close so to create some random numbers we'll need to instantiate a random object type random with an uppercase r random with lowercase r equals new random parentheses semicolon so the name of our random object is random really you couldn't name this anything but i usually just call it random and we can use this object to generate random numbers and there's a few built-in methods of this random object to access them add a dot and we'll focus on the next method and next double method next we'll generate a random whole integer so we'll want to specify a range this by itself will generate a random number between i believe zero and just over two billion so we'll probably want to set a range let's pretend that we're rolling a six sided dice i need a random number between one and six so i can set that range within the parentheses so the minimum would be one comma and the max would be technically seven because the second number is going to be exclusive so this will give us a random number between one and six just specify the range and we'll store this within a variable int num equals random.next a random number between one and a six all right then let's display this console.writeline num and we should have a random number between one and six and we got six all right then you can always make adjustments to this too like you can add i don't know 100 and that should give us a number between 101 and 106. so that's always an option too okay now what if you need to roll a 20-sided dice like we're playing dungeons and dragons we use polyhedral dice so that would be 1 comma 21 and this will give us a random number between 1 and 20 and we rolled an 8. now there is a next double method which will generate a random decimal number so let's say double num equals random dot next double and the random number will be between 0 and 1. so we have 0.701 something something something something so if you need a random decimal or random double number you can use random.next double otherwise if you need a random hold integer you're better off using the next method of random now if you need let's say three random numbers we can keep on reusing the same random object we only need to instantiate it once let's say we're going to roll three dice so three six sided dice let's copy what we have and paste it twice so we have num1 num2 num3 then let's display these console.writeline num1 num2 and num3 so we will have three random numbers and the result is three six and four well okay then everybody that is how to generate random numbers in c sharp i will post this code to the comment section down below if you can give this video a thumbs up drop a random comment down below and well that's how to generate random numbers in c sharp hey what's going on people it's bro hope you're doing well and in this video we're going to create a small program to find the hypotenuse of a right triangle in c sharp so sit back relax and enjoy the show everyone i thought for practice we could create a small program to find the hypotenuse of a right triangle this will be more or less just for practice so we'll need some prompts let's ask for sides a and b let's begin with a enter side a and then we'll store the user's input within a double double a equals and we'll convert the user input to a double convert to double then within the parenthesis console.read line then another set of parenthesis make sure there is a semicolon at the end too okay then for side b we can just copy what we have change any instance of a to b enter side b double b and we'll have to calculate whatever c is double c math dot square root then we need to multiply a times a that's effectively a to the power of two plus b times b and let's display the result console.writeline the hypotenuse is plus c and let's give it a go okay enter side a how about three enter side b four the hypotenuse is five well everybody that was a very small practice program if you would like a copy of this code i will post this to the comment section down below if you can give this video a thumbs up drop a random comment down below and well that is a very small sample program in c sharp hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to show you all some useful string methods in c sharp so sit back relax and enjoy the show all right everybody here's a few useful string methods that you may be interested in so to begin we'll need a string to work with or a variable containing a string so why don't we create a variable named full name to store your own full name now to access some methods available to strings we'll need to type a string or a variable containing a string then follow this with a dot and there should be a prompt for a whole bunch of methods that we have access to i'll show you some of the more useful ones like two upper full name dot to upper then to invoke this add a set of parentheses then a semicolon to finish this statement but then we'll need to reassign this full name equals full name to upper then we can display our full name and when i run this my name should all be uppercase just like that okay now alternatively there's two lower it's the same process as before but change the method to lower and my name should all be lowercase okay so that's two upper and two lower let's move on for this next example we'll need a phone number so let's create a string named phone number equals and make up some phone number and be sure to include some dashes one two three four five six seven eight nine zero okay what i'm going to do is replace these dashes with a different character so to do that we'll need to use the replace method so phone number dot replace so within the set of parentheses we'll need the character we're going to replace and another character we're going to replace the old character with so i would like to replace all dashes with a forward slash so separate each of these characters with a comma so this will replace my phone number the dash is within the phone number with forward slashes phone number equals phone number dot replace and let's display our phone number with a right line statement so all of these dashes have been replaced with forward slashes now if you replace these with no characters just an empty set of quotes that will effectively remove those dashes within the phone number which could have some uses too so that is the replace method available to strings next we have the insert method we can insert a character or a string at a given index within a pre-existing string let's say i would like to take my full name and turn it into some sort of username by preceding my first name with the at sign so to do that i can use the insert method i'll create a new variable for this example let's say string username equals full name dot insert and with the insert method we will list an index and what we would like to insert so computers they always start at zero the beginning would be zero that would be the first index so at the beginning index zero i would like to insert an at sign and this will create a new variable called username so i will display that within a rightline statement console.writeline username and my username is now at whatever my full name was now this doesn't necessarily have to be a single character we could say like mr dot and precede my full name with mr and my username is now mr bro code okay so that is the insert method what i'm about to show you next technically isn't a method it's a property but it's found within the same place as methods for strings so to access the length property of a string type a string dot link and you do not add a set of parenthesis afterwards that is done with methods so the length property will return the given amount of characters within a string so i'm going to display this within a rightline statement if you need this you can always like assign this to a variable or something but that might be overkill for this lesson so console.writeline the length of my full name and my full name has eight characters in it one potential use of the length property of strings is that let's say that somebody's creating a username and there's a max 12 characters well you can get the length of whatever they type in and check to see if it's more than 12 characters this next method is the substring method and it can be a little complex basically speaking we can take a section from an original string and create an entirely new string but we have to specify a position and how many characters you would like to extract from that given position so we'll create two new strings from full name first name and last name using the substring method so let's declare string first name equals full name dot substring okay so within the substring we're going to list an index and the amount of characters afterwards we would like to include within our substring so i would like to take the first three characters from my full name so the index computers always start with zero of the beginning of my string would be zero and i'm going to take three characters after this index so if i was to display my first name now it's going to be bro the first three characters of my full name now let's do the same thing with last name so let's copy what we have change first name to last name but now we have a different index so i would like my substring to begin where the c is so let's count what the index is going to be this would be 0 1 2 3 four so let's change zero to four and how many characters would we like to include within our substring one two three four so four comma four and that is my last name so i will display that within a writeline statement first name and last name so that is the substring method we can take a section or a slice from an original string and create an entirely new string from it all right everybody those are a few useful string methods but not all of them so if you would like a complete list you can always type a string dot and there should be a pop-up for all of the different string methods you can access and if you highlight one of these there's a description of what they do exactly i only showed you a few of the more useful ones for beginners so if you can give this video a big fat thumbs up drop a random comment down below and well those are some useful string methods in c sharp all right people if statements an if statement is a basic form of decision making if some condition that we specify is true we can execute a block of code if it's not true we can do something else entirely so let's write a small program where we will ask a user to enter in their edge and depending on their age we can write an if statement that checks to see if somebody is 18 years or older let's say that a user is signing up for a credit card and you have to be 18 years or older so if their age is greater than or equal to 18 we will display a message that says you're now signed up if they're less than 18 we can do something else so to write an if statement we just write if then parentheses to hold some sort of condition which we would like to evaluate followed by a set of parentheses so if some condition that we set within the parentheses is true we will execute this block of code if it's not true we skip over it entirely so let's check to see if age is greater than or equal to 18 then we will display something console that right line you are now signed up and let's try it please enter your age let's say that i'm 21 i hit enter boom you are now signed up now what if i enter in an edge that's less than 18 let's say that i'm 12 years old and i'm trying to sign up for a credit card well nothing appears to happen and that's normal so if this condition evaluates to be true we execute this block of code if it's false we skip over it entirely as if it never existed now we can take a different course of action if our above condition is false we can perform some other block of code so let's display a message that says you must be 18 years or older to sign up you must be 18 plus to sign up so if this condition is true we do this if it's false we do this so let's try it again please enter your age let's say that i'm 12 i hit enter you must be 18 plus to sign up so if this is true do this if it's not true do this now between the if and else statements you can add an else if statement if there's more things they want to check before reaching the else block so the else block is kind of like a last resort if all of buff statements evaluate to be false let's check to see if somebody's age is less than zero else if age is less than zero then we will display a custom message such as you haven't been born yet please enter your age i am negative 12 years old you haven't been born yet with these else if statements you can add as many as you want between if and else let's add another so i will copy what we have let's check to see if somebody's age is greater than 100 if it is then we'll say i don't know you're too old to sign up that's kind of mean i guess but it serves the purpose of this example so you are too old to sign up now we're going to run into one issue okay please enter your age i am 101 years old you are now signed up now the reason that this block of code executed and not this one is that we're just going down an order starting from the top since age which was 101 is technically greater than or equal to 18 this condition evaluated to be true and we executed this block of code and skipped everything else after it and continued on to the rest of the program so if we first want to check to see if somebody's age is greater than 100 we should probably put that within the if statement and check that first because age is technically greater than or equal to 18 if we set age to be 101 else if we will check to see if age is greater than or equal to 18 then we just have to change these lines of text around so you are too old to sign up so the order of these if statements and else if statements does matter and let's try it again okay please enter your age i am 101 years old you are too old to sign up all right now in this next example let's ask a user for their name instead of their age let's change int age to string name and we do not need to convert this because it's already a string so to check to see if somebody does not enter in some user input we can check to see if our variable name equals an empty set of quotes so this is an empty string now the reason that we're using two equal signs is that this is a comparison operator if you just use one that is an assignment operator c sharp thinks you're attempting to assign name with an empty string so we're comparing if these two are equal so that's why we use double equals so if name is equal to an empty string that means that somebody skipped over entering in some user input so let's yell at them you did not enter your name so if our name is not empty we can display maybe hello whatever the user's name is so hello plus name and let's try it okay please enter your name i'm just going to hit enter you did not enter your name let's run this again and take it seriously this time please enter your name bro hello bro now there's another way in which we could write this so instead of using this double equal sign we can use exclamation point equal sign that means not equals if name does not equal an empty string then we will display hello name else we will display you did not enter your name so we're checking to see if name is not equal to an empty string and if that's true display hello name okay please enter your name i'll hit enter you did not enter your name let's try it again please enter your name bro hello bro all right everybody those are if statements they're a very basic form of decision making we can check to see if some condition is true if it is true then we can do something if not we can do something else so if you would like a copy of both examples from this video i will post that code to the comment section down below and well those are if statements and see you sharp hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to explain switches in c-sharp so sit back relax and enjoy the show all right everybody switches a switch is an efficient alternative to writing many else if statements i wrote a small program we'll ask a user what day is it today like what day of the week and we'll store their input within a variable named day if day equals monday we'll write it's monday and we have else if statements for every day of the week that follows after and an else block at the end day is not a day they type in something that's obviously not a day using else if statements back to back like this really isn't that efficient and if a veteran programmer sees you do something like this they'll probably call you a noob a few else if statements is okay but this is somewhat excessive so let's rewrite this program so that we use a switch instead here's how to create one we'll keep our prompt too so switch parentheses curly braces within the parentheses we will place what we would like to examine we will examine our day variable against many cases and if there is a match then we will execute some block of code so to write a case write case then some value like monday then end this with a colon so anything indented after our case is part of the block of code for this case so if we have a match if day equals case monday then let's write it's monday then on the next line add a break to exit the switch okay so that's one case let's write a case for each day of the week and i'll just fast forward this footage and our switch is now complete although i did not add that line from the else statement quite yet we'll take care of that a little bit later so let's run this just to test it so what day is it today let's say that it's sunday enter it's sunday nice one thing that we're missing although it's optional is a default case if there's no matches what we want to do so currently there is no default case within the switch so what day is it today if i write something incorrect like pizza well the switch technically doesn't do anything so if there are no matching cases let's do something and we type default colon space if there are no matching cases we will perform this block of code at the end so let's write something day plus is not a day and then break and let's try it again so this is kind of like our else statement okay what day is it today this time let's say it's birthday birthday is not a day all right everybody those are switches they're efficient alternatives to using many else if statements if you would like a copy of this code i will post this to the comment section down below if you can give this video a thumbs up drop a random comment down below and those are switches in c sharp all right logical operators we can use logical operators to check to see if more than one condition is true or false we'll use two logical operators and as well as or and is represented by two ampersands and or is represented by two vertical bars we'll create a small program to ask the user what the temperature is outside and depending on what the user types in will display a custom message so we'll need to work with ranges of temperatures so let's begin we'll ask the user for some input so console.writeline what's the temperature outside and you can write this in fahrenheit or celsius but i'll use celsius okay then we'll store our input within a double variable named temp short for temperature and we'll need to use console.read line and then we'll need to convert this to a double using convert dot 2 double method so convert dot 2 double then within the parenthesis place your redline method within here okay now we need to check to see if our temperature falls within a certain range using an if statement and using the and logical operator that will help us with that so let's check to see if our temp is greater than or equal to 10 degrees celsius and if our temperature is less than or equal to what about 25 so both of these conditions must be true in order for us to execute this if statement if one of them is false we will skip over this if statement so this condition needs to be true and this condition needs to be true so our temperature has to fall within that range so we will display a custom message like it's warm outside it's not hot it's not cold it's just warm let's try it okay so what if the temperature was like 35 degrees celsius well nothing appears to happen we did not execute this if statement even though this condition is true this condition must also be true because we're using the and logical operator so let's try this again and type in a temperature between that range what's the temperature outside let's say that it's 15 degrees celsius it's warm outside now using the or logical operator only one of these conditions needs to be true in order for this entire expression to evaluate to be true unlike with the analogical operator both conditions must be true so let's check for some extreme temperatures using an else if statement else if temp let's say is less than or equal to negative 50 or temp is greater than or equal to 50 then we will display do not go outside let's try it okay what's the temperature outside let's say that it's negative 52 degrees celsius do not go outside so even though this condition is true and this one is false using the or logical operator only one of these conditions needs to be true in order for our entire expression to evaluate to be true so let's do the same thing with a very high temperature this time what's the temperature outside let's say that it's like a kajillion degrees celsius maybe our sun explodes or something do not go outside well okay then everybody those are logical operators we can use them to check to see if more than one condition is true or false so if you would like a copy of this code i will post this to the comment section down below and well those are logical operators in c sharp all right while loops a while loop will repeat some code while some condition remains true we'll write a small program where we will ask a user to enter in their name if they do not enter in anything we will keep on prompting them to enter their name they have to enter something in order to escape the loop so this is what we'll do to begin with let's create a prompt to ask a user for their name i'll use a write statement instead of a writeline statement and let's say enter your name and then we will declare a string variable named name the console.readline and then store that within variable name and then at the end of our program we'll say hello plus name okay so after running this what if a user doesn't type in anything like they just had enter hello and then there's nothing here so what if we try and force the user to enter in something we can write this code within a while loop so after we accept user input for the first time let's check that user input and we'll use a while loop our condition will be while name is equal to an empty string we will prompt the user again to enter in something for their name and we do not need to declare name twice name equals console.readline so let's try this again our condition is we will continue this while loop this section of code as long as name equals an empty string if they just hit enter so let's try it okay enter your name i'm going to hit enter enter your name no enter your name no and to your name no okay i'll type in something hello bro so with a while loop you'll need some way to eventually exit the while loop otherwise that is known as an infinite loop and here's an example of an infinite loop i'm going to say while one is equal to one and then let's display something else such as help i'm stuck in an infinite loop so basically we have no way to change this condition so it's always going to be true and we will repeat this code forever so let's try it again okay enter your name help i'm stuck in an infinite loop so with a while loop you'll eventually want some way to eventually exit the while loop now to optimize this code we don't technically need this right statement here because we will ask that within the while loop and i'm going to declare string name and assign this an empty string so this would work the same as before as well so enter your name i do not type in anything and we are prompted again to type in our name and i'll type in something well okay then everybody those are while loops they will repeat some code while some condition remains true and it will do so infinitely until this condition becomes false if you would like a copy of this code i will post this to the comment section down below if you can give this video a thumbs up drop a random comment down below and well those are wild loops in c sharp okay for loops a for loop will repeat some code a finite amount of times unlike with while loops a while loop will execute an infinite amount of times as long as its condition remains true for loops are limited so let's create a for loop to i don't know count to ten so let's create a for loop by typing four parentheses curly braces and within the for loop the parentheses of the for loop there's three separate statements we're going to fill in the first is that we need some sort of counter or index to keep track of which iteration we're on within the for loop so let's declare an index int index and i will assign zero to begin with so people usually just shorten index to simply i for short so that is the first statement the second statement is our condition when do we want to stop so let's stop when i is greater than or equal to 10. so we'll just say i is less than 10. so it's kind of like we'll continue this for loop as long as i is less than 10 and once we hit 10 we'll stop and then the third statement is how much do we want to increment or decrement our index by so you can write i plus equals one to increment by one or another variation is just i plus plus so after each iteration we'll increment i our counter our index by one and during each iteration let's display whatever i is so after running this code we will execute this for loop ten times and we will count the numbers zero through nine so if we want 1 through 10 we can change our index to 1. into i equals 1 and we will continue this for loop as long as i is less than or equal to 10 and then our for loop will execute a total of ten times and count the numbers one through ten and you can also skip iterations too like we can increment our index i by two i plus equals two now this for loop is going to execute five times we're incrementing our index by two during each iteration let's change this to three i plus equals three and this will execute four times one 4 7 10. okay let's do something a little bit different let's count down let's pretend that we're counting down to a new year so we'll start at 10 and count down to one then display happy new year so four parentheses curly braces we'll set index i to equal 10 to begin with we'll continue this as long as i is greater than zero then we will decrement i by one during each iteration so you can use minus minus or minus equals one either variation works okay so after each iteration we will display i then when we exit our for loop we will display happy new year within a rightline statement so happy new year let's try it okay 10 9 8 7 6 5 4 3 2 1 happy new year so everybody those are for loops they will repeat some code a finite amount of times unlike with a while loop a while loop will execute some code infinitely as long as its condition remains true a for loop is limited in that regard well everybody those are for loops if you can give this video a big fat thumbs up drop a random comment down below and well those are for loops in c sharp hey what's going on everybody it's you bro hope you're doing well and in this video we're going to use nested loops to create a program to draw a rectangle for us made out of a certain symbol that we choose so sit back relax and enjoy the show all right welcome back so nested loops a nested loop is a loop that's inside of another loop there is an outer loop and an inner loop and both of these combined are nested loops so the uses they vary they're used a lot in sorting algorithms so i thought let's create a program where we will draw a rectangle we'll have the outer loop in charge of counting the rows and the inner loop in charge of counting the columns and we will let the user choose a symbol that they would like to create their rectangle of so we'll need to accept some user input so console.writeline let's ask how many rows how many rows actually let's make this a write statement okay and then we will store this within int rows equals then we will need to convert some user input convert 2 and 32 because user input's always a string then within the parenthesis console.read okay let's ask for columns so let's copy this paste it how many columns int columns then let's ask the user for a symbol to use what symbol or character and let's use a string i guess you can use a char as well string symbol and we do not need to convert this because it's already a string okay we'll have an outer loop in charge of counting the rows and the inner loop is in charge of counting the columns so four then we need our index by the way it doesn't matter if you use a while loop or a for loop it's just the concept of having a loop inside of another loop i just so happen to be using a for loop for the outer loop and a for loop for the inner loop so into i equals zero we will continue this as long as i is less than our rows because we're letting the user choose how many rows then we will increment i by 1 during each iteration now we need an inner for loop and let's just copy this now one naming convention with the index of the inner for loop since i is already taken what people usually use for an index for the inner loop is j because j comes after i i guess so into j equals zero j is less than columns than j plus plus okay now what we'll do within the inner for loop is display our symbol so console dot right make sure you use right and not right line we will display our symbol so this inner loop is in charge of the columns the outer loop is in charge of the rows basically how this is going to work is that once we enter our outer for loop we will immediately enter our inner for loop in order to complete one iteration of the outer for loop we have to finish all iterations of the inner for loop and once we finish all iterations of the inner for loop we can complete one iteration of the outer for loop and during the next iteration we have to do it all over again so on the next iteration we would have to complete all the iterations for the inner for loop so this will display a rectangle made out of a certain symbol however there is one thing missing and i'll show you how many rows let's say four how many columns five and what symbol uh what about the i don't know that sign all right so this ended up in one long row so after we complete our iterations for the inner for loop we should probably move down to the next row kind of like a typewriter we finish one line then we move down to the next row so let's use an empty rightline statement just to move down to the next line so if we try this again okay four rows five columns let's use an at sign there we go there's a rectangle we have one two three four five columns and one two three four four rows so basically a nested loop is really just a loop that's inside of another loop when you'll encounter it it really varies but they're used a lot in sorting algorithms and this was a small program just to practice working with nested loops alright so if you want a copy of this code i will post this to the comment section down below if you liked this video give it a thumbs up drop a random comment down below and that is an example of nested loops in c sharp hey everyone it's you bro hope you're doing well and in this video we're going to create a number guessing game in c sharp so sit back relax and enjoy the show all right let's create a number guessing game we will randomly generate some random number between a set minimum and maximum and we will let the user guess as to what the number is if the number is too high or too low we will give a hint and the user can keep on guessing and we'll keep track of how many attempts it takes so we'll need a random object to generate some random numbers random random equals new random and there's a few other things we'll declare as well at the top boolean play again so if the user would like to play again we can keep this as true if they would like to quit we can set this to be false int min this will be the minimum value let's have the user guess a number between 1 and 100 int max but you can feel free to adjust these max equals 100 and guess i will declare this but not yet assign a value and number and int guesses okay we'll create a while loop and we will let the user decide if they would like to play again so our condition while play again equals true but since this itself is a boolean variable you don't technically need this equals true portion you could just say while play again because this by itself would evaluate to be true or false now if our user decides they would like to play again we should probably reset everything so let's take our guess and set the sequel to zero guesses this is the number of attempts that equals zero as well and let's generate a new random number number equals random dot next and within the parentheses of the next method we can list our minimum and maximum but remember that this number is exclusive but since we have these variables we can place these here instead so min and max so this should be max plus one this will generate a random number between one and one hundred because like i said this number is exclusive okay then we will keep on asking the user to type in a number like guess again so we'll need a nested while loop while and our condition is guess does not equal our number that is randomly generated so let's ask the user to type in a number guess a number between and this next part is going to get a little funky plus min plus i'll add a dash plus max plus a colon okay then we will take variable guess equals and we'll need to convert some user input convert to int 32 and within the parentheses console dot read line all right then we will display whatever our guess is console.writeline guess colon space plus guess and now we need to check our guess versus the number and we can use an if else if statement if and the condition is guess is greater than number we will display a hint console that right line let's say that guess plus is too high elsif and the condition is guess is less than number let's copy this guess is too low and then if guess equals number we escape the while loop oh and we do need to increment our guesses by one after each guess so let's place that right about here right before we do another iteration of our while loop guesses plus plus to increment our guesses by one now when we exit the while loop that means that we eventually got the right number so we will display the number with a rightline statement console.writeline number colon space plus number then we will display you win console.writeline you win and let's display how many guesses it took how many attempts guesses call in space plus guesses then we should probably let the user decide if they would like to play again and actually let's declare one more variable string response and then we will assign this within the while loop let's do that here we'll reset it response equals an empty string okay then we'll have the user type in if they would like to play again would you like to play again y slash n so they would have to type in either y or n y to play again for yes and for no response equals console dot read line and let's make this uppercase in case they type in something that's lowercase response equals response dot to upper so if our response is equal to a capital y play again equals true else play again equals false then when we escape our outer while loop that means we are done playing this game so let's find where that ends right here okay let's say thanks for playing oh looks like i typed that already so just type this in i guess all right we're good so let's run this guess a number between 1 and 100 what about 50 that's right in the middle right 50 is too high what about 25 25 is too high what about 12 12 is too high this is a very low number i guess what about six six is too high g's all right three three is too low our number is between three and six how about four four is too low five all right finally so it took seven guesses let's play again i think i can do better guess a number between one and one hundred let's go with 50 again 50 is too low so something between 50 and 100 let's go with 75 75 is too high uh what about 63 63 is too high uh 57 57 is too low how about 60. all right 60. that took five guesses this time would you like to play again no thanks for playing well everybody that was a very simple number guessing game in csharp i'll post all of this code to the comment section down below if you would like a copy for yourself if you can give this video a thumbs up feel free to drop a random comment down below and well that is a very simple number guessing game in c sharp hey what's going on everybody it's you bro hope you're doing well and in this video we're going to create a game of rock paper scissors in c-sharp so sit back relax and enjoy the show all right everybody let's create a game of rock paper scissors what i like to do is declare all the things that we'll need at the top of our program we'll need a random object to generate a random number for the computer's choice so we'll say that one equals rock two equals paper and three equal scissors so we'll need to create a random object random random equals new random and we'll create a boolean variable named play again and i will set this to equal true so if the player decides to exit they would not like to play another game we can set this to be false and we'll need a string variable to hold the player's choice i will declare this but not yet assign it so this will store rock paper or scissors and we'll need a string variable for the computer's choice as well okay that's all of the different variables that we'll need so let's create a while loop while play again equals true now if we're working with boolean variables we technically don't need this equals true portion because this by itself would evaluate to be true or false so you can just say while play again and that would work as well and then if the player decides to quit we can change that to false okay now let's ask for some user input console without right enter rock paper or scissors and we will store the user's input within string variable player player equals console.rt line now strings are case sensitive what i'm going to do is take the player's input and make it all uppercase just so that everything is consistent player equals player dot two upper i guess you could make this all lowercase two okay now let's display the player's choice with a right line statement so what if the player decides to choose something that isn't rock paper or scissors we would want some way to enforce that so let's say that i choose the gun and that's a valid response so we should probably prevent the player from doing so so what we'll do is use a nested while loop so while then surround this section of code within a set of curly braces and we will continue to prompt the user to type in something that is valid a valid choice so this is our condition while player does not equal rock and i'm just going to copy this player does not equal paper and player does not equal scissors so we'll need to assign player and computer a value let's do that at the top of our while loop for play again so player equals an empty string and computer equals an empty string so this is kind of nice when we do play another round we can reset player and computer okay let's try this enter rock paper or scissors i pick the gun enter rock paper or scissors how about a bomb fist nope okay so we have to choose either rock paper or scissors what about rock cool so that is a valid response okay so let's get rid of this right line statement we won't really need it anymore now we'll need to generate a random number for the computer player one two or three and i will use a switch so we will place the random number that is generated within the parenthesis we could say like i don't know int random num equals random dot next and the range is going to be one through four so remember that this number is exclusive this will generate a random whole number between one and three okay then what i'm going to do is technically we don't need this portion like we could place random num within switch but what i like to do is kind of shorten and condense my code so i'm going to take this method of random.next and place it within the switch itself and that would work as well so let's examine some cases case 1 that will be rock computer equals rock all uppercase then break and we'll need case two in case the random number is two case two computer equals paper then break and case three computer equals scissors then break what i'm going to do after our switch is display the player's choice along with the computer's random choice so let's use a redline statement so player colon space plus variable player then let's create another right line for the computer computer plus computer let's run this okay i will choose rock player rock computer scissors let's play again i will choose paper player paper computer paper and scissors player scissors computer scissors okay now we just need to examine our choices and see who wins that's the next step now what we'll do at this point is create a switch to examine the player's choice versus the computer's choice and we can decide who wins so let's create a switch and we will examine the variable player against many different cases so the first case will be rock and for now we'll just break we'll fill this in a little bit later case paper break and case scissors and break all right we're going to check to see what the computer picked so if computer is equal to rock then it's a draw so let's write it's a draw i think i'm missing a break statement all right then else if computer equals paper that means that we lose else if computer equals paper then we will write you lose else technically we don't need a condition because the only choice left is scissors for the computer else you win so let's copy these statements paste it underneath paper so if we choose paper and the computer chooses rock that means that we win so let's change this to you win if we choose paper and the computer chooses paper that means it's a draw else you lose let's copy this again paste it underneath scissors so if we pick scissors and the computer picks rock you lose if we choose scissors the computer picks paper then we win you win else it's a draw all right let's test it all right enter rock paper scissors let's go with rock rock paper you lose let's choose paper this time paper scissors you lose again and let's try scissors scissors rock you lose man i kind of suck at this game let's try it again paper paper rock okay i finally won one cool now at this point we're going to let the player decide if they would like to play another round so place this code at the end of our outer while loop so i'm just going to follow the dots here so that would go right here all right so let's use a write statement would you like to play again y slash n so y for yes and for no actually i think i'm going to create another variable so let's do so at the top string answer and we should probably reset this to answer equals an empty string okay so we will add one more variable okay answer equals console dot read line then let's make it uppercase in case the player enters in something that is lowercase we'll still count it answer equals answer dot to upper then let's check to see what the player enters in if answer is equal to y then play again equals true else play again equals false all right then outside of the while loop we will display a goodbye message maybe we'll say thanks for playing all right let's try it one last time okay enter rock paper scissors always choose rock player rock computer paper you lose would you like to play again yes let's pick rock again rock paper you lose okay maybe you don't always pick rock would you like to play again no because this is a dumb game thanks for playing well okay then everybody that is a game of rock paper scissors if you would like a copy of this code i will post this to the comment section down below if you can smash that like button leave a random comment down below and well that's a game of rock paper scissors for c-sharp alright people well i thought for practice we could create a sort of calculator program we can pick two numbers we can add them subtract them multiply them and divide them so let's get started this will be just a very simple project i'm going to write just calculator program when we begin this program and then maybe i don't know format it a little bit let's add some i don't know dashes or something just to kind of make this look nice this will all be within the console okay so we'll need to declare num1 num2 and result these will be doubles double num1 i'll set this equal to zero let's create num2 and result double result and i will set that equal to zero as well okay we will need to ask for some user input console the right line enter number one colon space and then we will assign num1 equals so user input's always a string we'll need to convert this to a double convert dot to double and within the parenthesis we need console.read line method okay let's do the same thing for num2 enter number two num2 equals convert.2double pass in console.readline now we need the user to type in an option do they want to add a subtract multiply or divide so let's type enter and option console.writeline again what about plus colon space add then minus colon space subtract asterisk for multiply and forward slash for divide you can add other options if you want to okay let's take a look at this so far so we have calculator program enter number one what about 3.14 enter number two uh let's say i don't know five okay a couple things i'm going to change real quick i'm going to change this right line to just right then i'm going to add a tab escape sequence that is backslash t for tab just so that it looks better okay let's continue so i'm going to create a switch that will read our user input switch console.read line and we need matching cases case plus so if somebody would like to add we will take our result equals num1 plus num 2. console.writeline and i'll do some string interpolation your result colon space num1 plus num2 equals plus result and then we need to break out of this case okay let's do the same thing with minus case minus result equals num1 minus num2 num1 minus num2 and that's all we need then we need multiply case asterisk result equals num1 times num2 replace minus with asterisk and then divide case forward slash for division result equals num1 divided by num2 and replace the asterisk here and then we should probably add a default case just in case somebody doesn't pick one of these options default console.writeline that was not a valid option and then break enter number one 3.14 enter number two uh let's say 6.9 and i would like to multiply these so i will add an asterisk 3.14 times 6.9 equals 21.666 all right i'm just going to change one thing i'm going to add one line right before we read our user's input for what operation they would like to use so let's add console dot right now right line enter an option then let's try it again 3.14 multiplied by 6.9 is 21.666 okay now what if somebody would like to continue using this calculator so what we'll do is place all of this code within a do while loop i'm not sure if i discussed this in the past but a do while loop will always execute a body of code once and then it checks the condition at the end so let's add that here so we have do at the top then we need our while with condition while all right now before this let's ask for some user input console.writeline would you like to continue capital y equals yes capital n equals no and then we will read some user input so within the while loop the condition this will be console.readline dot 2 upper so in case they type in lowercase y or n we'll just change it to uppercase via the two upper method and let's check to see if this is equal to y if it is then we'll reset our num1 num2 and result variables and do this all over again and if they would not like to continue let's write buy okay let's try this again what is point one four divided by two so enter number one three point one four enter number two two and let's divide these the result is one point five seven let's type y for yes all right then we can do this all over again what is 5 divided by 3.14 so i will divide and the result is 1.59 something something something would you like to continue i'm going to type and for no bye so yeah that's a very simple calculator program in c sharp i will post this code in the comment section down below if you can give this video a thumbs up leave a random comment down below and subscribe if you'd like to become a fellow bro hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to explain a raise in c sharp so sit back relax and enjoy the show all right everybody so arrays think of an array as a variable but it can store multiple values not just one so i have the string variable named car and it contains the name of a car bmw so what we could do is turn this variable into an array so it can store multiple values and this is all you have to do after the data type add a set of square brackets and then surround all of the values with a set of curly braces boom you got yourself an array and that's all there is to it so you can add multiple values to this array named car and actually i'm going to rename this as cars so it's plural so that we know that there's multiple values within here so let's separate each value with a comma so let's say we have a bmw a mustang as well as a corvette okay then let's display what cars is with a right line statement console the right line cars so this is what appears we have the data type of our array instead of the values within the array so if you need to access an element that is an item from an array you need to add after the variable name well the array name a set of square brackets and then the index so computers they always start with zero the first element would be zero so place that number within the square brackets cars at index zero and the first element would be bmw so let's display the other elements let's just copy what we have okay let's display cars at index 1 that will be this value because this is index zero and that is mustang then the next value cars at index two and that is corvette so let's take a look to see what happens if i attempt to access an element that doesn't exist so cars at index three so that would be something beyond corvette so we'll actually run into an error we ran into an index out of range exception so arrays do have a fixed size you have to make sure that you're not accessing an element that doesn't exist now if you need to update an element within an array all you have to do is type the array name in this case it would be cars straight brackets and list the index so if i need to change the first element within my array i will say my arrand name cars at index zero equals let's place a tesla there instead and then run this so instead of a bmw in the first position index zero we have a tesla so if you need to access or update an element within an array type the array name straight brackets and then the index and remember that these always start with zero so what we've done here to display the elements of an array is that we wrote a writeline statement for each individual element so a much better approach would be to iterate over our array using a for loop and later on i'll explain the for each loop so to display all of the elements of our array easily let's create a for loop so we'll say into i equals zero will continue this as long as i is less than now arrays have a length property so type the name of the array dot link then i plus plus to increment our index okay with our writeline statement let's display cars straight brackets and the index is going to be i so i is zero for the first iteration then during the next iteration it will be one then two and then it will stop because this statement will no longer be true okay let's try this again so we have tesla mustang and corvette so an easy way to display the elements of an array is to write a for loop and set the index equal to i whatever you have right here but we'll have to discuss the for each loop coming up in a later video one thing that you should know with arrays is that they have a fixed size if you would like to declare an array and then assign values later you'll need to declare that array with a fixed size of how many elements you're planning to place within that array so that would look something like this let's turn this line into a comment and this is how to declare an array so type the data type square brackets the name of the array equals new the data type again square brackets and then within this set of square brackets we will list a size so if i plan on adding no more than three elements to this array i can place three here but you can make this a larger size to accommodate more values and if you don't use those values they'll just remain empty no big deal and this will work the same as before and then we'll just have to update some values so cars at index 0 1 and zero is a tesla one is a mustang and two is a corvette and this will pretty much work the same as before instead of just in one step declaring and assigning an array we have done it in two steps we declared the array and then assigned some values later well okay then everybody that is an array it's a variable that can store multiple values and they have a fixed size so that's something you need to pay attention to if you would like a copy of this code i will post this to the comment section down below and well those are arrays in c sharp oh yeah all right everybody for each loops a for each loop is a simpler and more elegant way to iterate over an array however it's less flexible compared to a standard for loop i have an array of names of vehicles named cars we have a bmw mustang and corvette then we can use a standard for loop to iterate and display the elements of this array so this works fine however it's a lot of work to write all of this another approach although it's less flexible is to create a for each loop this will iterate once for each element within my array so type for each parenthesis curly braces and within the parentheses we list the data type of each element then we need a name for each element that we're working with since we're working with cars let's call each element a car string car in the name of the array cars string car in cars then i will with the right line statement display whatever car is so this is kind of like a nickname for the element that we're currently working with so let's get rid of this for loop because we don't need it anymore and use our for each loop instead and this works the same as before one downside with a for each loop is that it's not flexible with a standard for loop we can iterate forwards backwards or even skip iterations so use whatever loop is more appropriate for your situation well everybody that is a for each loop it's a simpler and more elegant way to iterate over an array however it's not as flexible if you just need something simple to display the elements of an array you can easily use a for each loop all right everybody so that's a for each loop if you can give this video a thumbs up drop a random comment down below and well those are four each loops in c-sharp all right people methods a method performs a section of code whenever it's called also known as invoking a method and the benefit of using a method is that it lets us reuse code without writing it multiple times here's a scenario let's say that we have to write a program where we need to sing happy birthday to our friend three times because we would like to annoy him one way in which we could do that without writing a method is that we would need to display as output you know the lyrics to happy birthday i just made my own version of it so happy birthday to you happy birthday to you happy birthday dear you happy birthday to you if i need to sing happy birthday three times i would need to copy and paste this code two additional times and that would allow me to effectively sing happy birthday three times so after running this we have all of our text repeated three times now a better way of writing this would be to use a method where we only have to write this once and then we can keep on reusing it yeah let's delete all this outside of our main method that will end right here we need to create a new method and the way we do that is that for this specific case we have to write static because we're invoking a method from our main method which is static so we need static but not always void and then a unique and descriptive name of this method what does it do exactly so let's call this method sing happy birthday then a set of parentheses then a set of curly braces and we have ourselves a method named saying happy birthday and when we call this method what kind of code do we want to execute so let's copy and paste the lyrics to happy birthday and then place it within this method now to invoke a method or called method we have to type the name of the method followed by a set of parentheses and i like to think of the parentheses kind of like a pair of telephones they're communicating with each other that's how i think of it at least and then a semicolon to end the statement so after running this this will execute sing happy birthday once now if i need to sing happy birthday two additional times i can just call this method two additional times sing happy birthday saying happy birthday sing happy birthday and i do not need all of this text i only need to write it once and then i can just keep on reusing it and here we have the lyrics to my happy birthday song repeated three times let's move on to level two we're going to create a string variable named name string name equals and make up some name now what if we attempt to use this variable within our method so replace you with name happy birthday dear name okay here's the situation the name name does not exist in the current context methods don't have access to any variables within another method so anything within the main method this singh happy birthday method cannot see so we need to pass what are known as arguments over to this method in order to use these values or variables so when you invoke a method and you need to send arguments over to a method we just list whatever we would like to send over to this method within the parentheses so i would like to pass name as an argument to this method however we need a matching set of arguments and parameters parameters are kind of like what this method is expecting to receive and to create some parameters we list the data type of what we're expecting followed by some sort of name so let's just say name and now we can use this variable name that is declared within the main method and we now have our name variable displayed within our happy birthday song and here's how to send more than one argument to a method let's create an integer variable named age and we will display the user's edge within our happy birthday song so separate each argument with a comma we will pass name as well as age to our happy birthday method but remember we need a matching set of arguments and parameters so we need to add a age parameter so separate each with a comma then list the data type of this variable first int and then a name we'll just call it edge and now we can use this edge variable within our method so let's create a line where we will display the person's edge so console that right line u r plus age plus years old and let's try this again happy birthday to you happy birthday to you happy birthday dear bro you are 21 years old happy birthday to you i guess my happy birthday song could use some work now these parameters they don't necessarily need the same exact name as the arguments that we pass in let's rename name as birthday boy and replace edge with years old okay then replace any instance of name with birthday boy and age with years old and this will work the same so you can rename these parameters what's important is the data type and the order of the values that you pass in all right everybody well those are methods they perform a section of code whenever they are called also known as invoking a method and the benefit of using methods is that it allows us to reuse code without writing it multiple times we only had to write the lyrics to happy birthday once then if we had to sing happy birthday you know more than one time we can just keep on invoking this method however many times that we need so those are methods if you can give this video a thumbs up drop a random comment down below and well yeah those are methods in c sharp oh yeah the return keyword now the return keyword returns data back to the place where a method is invoked so let's create a method to multiply two numbers together something simple so when we declare a method we'll have to make sure that we do it outside of our main method so right here so we will say static void and we will name this method multiply and we'll need to pass in two numbers as arguments let's say that the data type will be double double x and double y okay now we would like to multiply these two numbers together and we will store them within double variable z double z equals x times y now to return data back to the place where it's invoked we can use this return keyword and what kind of data would we like to return let's return whatever z is now there's one change that we need to make we need to replace this void keyword with the data type of what we're returning exactly so since we're returning a double we'll change void to double if you're not returning anything you can just keep that keyword as void now we can use this multiply method to well multiply two numbers together so let's write a program where we will ask a user for some user input multiply two numbers together then return the result and display it so let's accept some user input and first we should probably declare the variables that we'll need double x double y and double let's call this result and we will ask the user to enter in number one and then assign x equal and we'll need to convert the user's input to a double because it's always a string when we accept user input x equals convert dot to double then out of side of parenthesis within the parenthesis console.read line and we'll do the same thing for variable y enter in number two and then change x to y now if we need to assign results a value we can use this multiply method so type multiply add a set of parenthesis to invoke it but we'll need to pass two matching arguments because we have two parameters set up we need to pass in two double values or variables so we will pass x and y as arguments to this method multiply so this return keyword will return whatever z is back to the spot in where this method is invoked and we will store the result within this variable named result and then we should probably display it let's display result and well that's it let's try it enter in number one have you always wondered what pi times 420 is well we're about to find out it is 1 318.8 so yeah that is the return keyword it returns data back to the place where a method is invoked and if you would like you can actually shorten this even further we don't necessarily need to store the result within you know a new variable we could just say return x times y and that would work the same too that is the return keyword it returns data back to the place where a method is invoked if you're able to give this video a thumbs up leave a random comment down below and well yeah that's the return keyword in c sharp let's go bros okay it looks like we're talking about method overloading now methods they can actually share the same name but you need a different set of parameters a method's name plus its parameters equals a method's signature and methods must have a unique method signature let's take this method for example called multiply so this returns a times b so what if i would like to multiply more than two numbers like three numbers well this method is only set up for two arguments so one thing that we could do is method overload so we can use the same name like we can reuse it but we need different parameters so to solve this problem i'm going to create a second multiply method and this will have a different set of parameters giving it a different method signature so let's create a method that has three parameters a b and c return a times b times c and you can see that that problem went away and this should work so 2 times 3 times 4 equals 24 and i can just keep on creating more methods so basically that's method overloading methods can share the same name but they need different parameters if they do share the same name a method's name plus its parameters equals the method signature and methods must have a unique signature so yeah that's method overloading if you would like a copy of this code i'll post this to the comment section down below if you can smash that like button drop a random comment down below and well yeah that's method overloading in c sharp oh yeah ladies and gentlemen do you know what's better than overloaded methods the params keyword now a methods parameters can take a variable number of arguments if we use the params keyword and the parameter type must be a single dimensional array what's the benefit of this let me explain so let's say that we have an online store we have a method to check out where we will basically sum up a customer's prices and return a total and we'll tell the customer you have to pay this total what if the person checking out has a variable number of items that they would like to buy well we would have to set up a bunch of different methods like what if they only buy one item well there's a checkout method that accepts one argument another checkout method that accepts two arguments then three and then we continue on and on and on so yeah don't do this a better solution would be to use this params keyword where we only need a single method and this one single method can accept a varying number of arguments we don't need like several copies of the same method then so to use the params keyword precede our data type with the word params then after the data type follow this with a set of square brackets now this parameter a is now an array i'm going to name this as something a little more descriptive like prices because we're working with prices so we need to iterate over the elements of an array and create a total so i'm going to create a local variable named double total so you can have variables with the same name but they need to be within a different scope so these are in different methods so they are not visible to each other double total i will set the sql to zero to begin with and we'll use a for each loop to iterate over the elements of this array for each double price in prices total equals total plus whatever price we're working with but i'll shorten this to plus equals price then at the end we will return total and this should work the same okay the total price is 24.74 but there's some formatting that we'll have to do in a future video and then i can just keep on adding items to my you know fictional shopping cart like i would like to buy a bottle of water for a dollar and a t-shirt for 10 and 25 cents so you see by using this params keyword a single method can accept a varying amount of arguments so method overloading isn't always necessary if you're working with a lot of different arguments you're not really sure how many arguments are going to be passed in okay then everybody that is the params keyword it can be applied to a method parameter so that it can accept a variable number of arguments but the parameter type must be a single dimensional array and that is the params keyword if you can help me out by smashing that like button drop a random comment down below and well yeah that's the params keyword in c-sharp hey well it looks like we're on exceptions today an exception is an error that occurs during execution so here's an example i have a small program where we will ask a user to type in two numbers divide those numbers then display the result so what if i type in something that's not a number i would like to divide the number 5 by the word pizza we'll encounter an exception and this interrupts our program we encountered a format exception input string was not in a correct format so any code that is considered dangerous where it might cause an exception we can surround with a try block so i would consider this code to be dangerous so type try then a set of curly braces surround any code that is considered dangerous with the set of curly braces now if we have a try block we also need a catch block so after the try block add catch and the catch block catches and handles exceptions when they occur but we need to specify what kinds of exceptions we would like to catch and handle so catch parentheses curly braces and this is kind of like a parameter so i would like to catch and handle any format exceptions then add e so if we encounter that same exception again instead of our program being interrupted we can do something else instead so let's write a message and let the user know to type in only numbers enter only numbers please and let's try that again enter number one five enter number two pizza enter only numbers please and this did not interrupt our program that's the important thing now these try and catch blocks they will only catch and handle format exceptions what if somebody accidentally divides by zero or intentionally does so so we do not have a catch block set up for that we can add multiple catch blocks so let's catch any divide by zero exceptions so catch parentheses curly braces and the exception we would like to catch is divide by zero exception then add e so if somebody attempts to divide by zero let's display a message you can't divide by zero idiot but this only occurs with integer division so let's turn our doubles x and y into integers and we'll have to change this cast as well so change to double to and 32. so if we attempt to divide a number by zero which we can't mathematically do this is what happens enter number one five enter number two zero you can't divide by zero idiot and this will not interrupt our program now you can add a catch block that just catches everything but it's not considered good practice to add by itself so sometimes i'll add a like catch all block just in case if there's any exceptions i do not anticipate so at the end we can add exception e but it's difficult to let the user know what went wrong exactly because it'll just print when any exception occurs something went wrong so this will catch everything let's remove the first two catch blocks so let's take five divided by the word pizza something went wrong now catch exception e does catch everything but it's considered poor practice to have this by itself because basically you're shrugging when something goes wrong you should let the user know exactly what went wrong so it's better practice to catch specific exceptions first then at the end you can add you know exception e in case there's anything you don't anticipate by the way i changed x and y back to doubles now the last thing we need to talk about is the finally block the finally block is optional it always executes regardless if an exception is caught or not so at the end let's create a finally block type finally curly braces if there's anything you'd like to do after you're trying catch block regardless if an exception occurs or not you can place that here what people typically use the finally block for is to close any open files if they need to reset anything but for this example let's just print something so let's display a thank you message thanks for visiting if we do not encounter any exceptions this finally block will still execute five divided by one is five thanks for visiting now if we do encounter and catch an exception well that finally block is still going to execute as well thanks for visiting so yeah those are exceptions they are errors that occur during execution they interrupt the normal flow of our program any code that is considered dangerous we should surround with a try block and catch any exceptions when they occur and finally can be added and it will execute regardless if an exception is caught or not so yeah those are exceptions i will post this code in the comment section down below if you can smash that like button drop a random comment down below and well yeah those are exceptions in c sharp all right welcome back we're talking about the conditional operator which is represented by a question mark so the conditional operator is used in conditional assignment if a condition is true or false and we follow this formula we have some sort of condition or expression then we add a question mark kind of like we're asking a question is this true if it is do x if not do y so we'll write a simple program to check the temperature outside so we'll write this using an if-else statement first and then later on we'll use the conditional operator and take a look at the differences so let's say we have a double named temperature and i'll set this equal to 20 degrees celsius as well as a string message i will declare this but not yet assign it so what if we would like to assign our variable message a custom message based on the temperature well if we're using if else statements that would look like this so we need a condition if temperature is greater than or equal to let's say 15 degrees celsius then we will assign message a string message equals it's warm outside else message equals it's cold outside and then at the end i would like to display my message within a writeline statement console that write line message and this will work just fine no issues so my temperature is currently 20 and this will print the message it's warm outside now there is a way to shorten this and that's by using a conditional operator so if we were to take that approach we would have to follow this formula so let me just copy this we need our condition our condition is temperature is greater than or equal to 15. question mark like we're asking a question if it's true then do this so we will take its warm outside in place of x if not then we do this it's cold outside but these are returning values so we need to assign them to something so we will say message equals this is our condition temperature greater than or equal to 15 question mark if that's true assign this if not assign that and that's all there is to it and we don't really need all of this anymore and then i will display my message within a redline statement and this will do the same thing it's warm outside you could even take this a step further too you could place just this within a right line statement and get rid of the message completely we don't even really need that message variable so yeah that's the conditional operator you can use this in conditional assignment if you need to assign some variable if some condition that you set is true or false it's kind of like a shortcut so yeah that's the conditional operator in c sharp all right what's going on people string interpolation string interpolation allows us to insert variables or values into a string literal we precede a string literal with a dollar sign and then any placeholders within a string literal that is interpolated we can use to insert values or variables within so here's an example of where string interpolation could be useful let's say we have three variables first name last name and age let's declare those string first name make up a first name string last name make up a last name and then an age okay so what if we would like to display somebody's first name last name and their age let's use a standard string literal first and we'll look at the differences so if i would like to display something like hello plus first name plus i'll add a space plus last name and then maybe add like a period at the end well i would have to concatenate all these separate strings together and then let me display age two console.writeline you are plus age plus years old so this works fine but an easier way is to use string interpolation so what we're going to do is create a string literal and then precede this with a dollar sign and then write a string normally hello wherever you would like to insert a value or variable add a set of curly braces as a placeholder and i would like to insert first name here then add a space and here within my string literal i will insert last name and then maybe add a period to the end and let's do the same thing with our second line so we need a string literal a double set of quotes precede this with a dollar sign you are curly braces age years old and this will do the exact same thing however it's less work so hello first name last name you are age years old another thing that you can do too is that when you display one of these values you can allocate some room after the variable name add a comma and then how many spaces you would like to allocate let's say that when i display my age i would like to allocate 10 spaces worth of room to display my edge and this is what that looks like you are then i have 10 spaces including the two digits in my age and if this was negative this would be left aligned so my age is all the way over here then i have eight spaces afterwards so yeah that's string interpolation it allows us to insert variables into a string literal we precede a string literal with a dollar sign and then curly braces with then as placeholders for values or variables so yeah that's string interpolation in c sharp if you found this video helpful please be sure to smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro alright what's going on multi-dimensional arrays so just a fair warning this is a difficult topic if you want you can skip this video you won't hurt my feelings but if you'd like to know what a multi-dimensional array is well here we go so a multi-dimensional array is an array of arrays so i have three standard arrays i have different car manufacturers ford chevy and toyota so each array has three different kinds of cars a multi-dimensional array is good if you need like some sort of grid or matrix of data so what i would like to do is to create an array of arrays to simulate maybe like a parking lot to park all of these cars so to create a multi-dimensional array this will be a two-dimensional array we need to list the data type of what we're storing strings then a set of straight brackets and then within the straight brackets add a comma so now i'm going to name this array let's say parking lot equals and then we add our curly braces much like what we do with standard arrays however i'm going to add each array within the set of curly braces and then separate each with a comma so this can be somewhat difficult to read i like to kind of condense it all and just make it look nice so you can see that this resembles sort of like a grid with rows and columns and that visual is going to help us so to access one of these elements we need to list an index for the row and an index for the column so let's say i would like to change this explorer to something else so in order to access this element i'm going to type the name of our multi-dimensional array straight brackets and then i need a row and column so these always start with zero this would be row zero row one row two i need to access row one so that would be zero then comma for column and then i need to count the row number zero one two so that would be zero comma two for this element within my two-dimensional array so i'm going to change this to something else so let's say that this is a ford fusion and then let's display these elements we can use a for each loop for each the data type is string let's say car in parking lot and then i will just iterate through these console.writeline card so this will iterate nine times one for each element within our two-dimensional array so we have a mustang f-150 then fusion so we updated explorer to fusion so let's update maybe this corolla to something else so let's count the row number that would be zero one two parking lot two and the column number is zero and let's say that this is a tacoma and try this again okay we have instead of a corolla a tacoma now if you would like to display this as like a grid we can use nested for loops for that so let's get rid of this for each loop i'll just turn this all into one giant comment okay so to display this as like a grid we'll use nested for loops the outer loop will be four and i equal zero we will continue this as long as i is less than parking lot dot get length method and then pass in the dimension so pass in 0 for the first dimension i plus plus and then we need a nested for loop so change i to j get length one so this represents the second dimension remember that these always start with zero and then change i to j plus plus so during each iteration of the inner for loop let's change this from right line to right i will display parking lot straight brackets i comma j then i'm just going to add a space to separate each car and then when we escape our for loop we need to go down to the next row so i'll use an empty right line statement so by using nested for loops we can display our two-dimensional array as sort of a grid or matrix so we have our mustang f-150 our fusion corvette camaro silverado tacoma camry and rav4 so if you ever need like a grid or matrix of data you can always use a multi-dimensional array and these are kind of the steps to set it up so yeah those are multi-dimensional arrays if you found this video helpful please be sure to smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro alright classes a class is really just a bundle of related code that you would like to organize together it can be used as a blueprint to create objects with object-oriented programming but we'll discuss that in the next video so my main method is located within a class named program the point of this class is well to group my program together but there are classes too that have certain functions for example the math class the purpose of the math class is to contain a bunch of useful methods related to mathematics and let's take a look at this so this class is named math and all that's in here is a bunch of methods related to mathematics so that's kind of the point of this class but we can create our own classes too now to create a class we can either do so outside of our class program or create a class within a separate c-sharp file i'll show you both ways so to create a class make sure that we're not writing this within our class program so that ends here type class and let's create a class to group a bunch of useful messages together like message methods class messages curly braces and let's create a few methods related to messages so this is going to be more of like a utility class void hello and when we use this method let's display a message like hello welcome to the program and let's create maybe two more void hello void what about waiting like we're waiting for something i am waiting for something and what about goodbye void bye bye thanks for visiting if you would like to create a class within a separate c-sharp file i would recommend opening your solution explorer if you don't have that open you can find it here go to view solution explorer right click on your namespace add class class and then i will name this messages add okay then i'm going to take my code from within this class cut it delete my class and then paste it within this class messages so you can either write your class within the same c sharp file or a different one if i would like to use some of these methods found within the messages class there's one of two things that i need to do i either need to create an object from this class or i need to precede my class definition with the word static followed by everything within my messages class so we'll talk about creating objects in the next video so for now we'll just have to use the static keyword and i'll create a separate video on this too and we should now be able to use these methods found within my messages class so if i need to display a hello message i would type the name of the class that would be messages then dot to access the members however these are not visible so we need to make them public and that'll be a separate video on axis modifiers so i would like this to be a public method so precede static with public and we should now be able to see those methods so type messages again dot and here are those methods i would like to use the hello method and that will display my message hello welcome to the program i also have that waiting message messages dot and that was waiting as well as goodbye messages dot bye so hello welcome to the program i am waiting for something bye thanks for visiting so basically a class is just a bundle of related code and it can be used as a blueprint to create objects otherwise you can use a class more or less as a utility class but when you define your class you'll have to precede the class definition with the word static and to make this public and accessible you would have to precede each method with public and static so yeah those are classes they're really just a bundle of related code you can use them as a utility class or use them as a blueprint to create objects which we'll discuss in another video if you found this video helpful please help me by smashing that like button leave a random comment down below and well yeah those are classes in c sharp all right objects an object is an instance of a class that means that we can use a class as a type of blueprint to create objects with object oriented programming so look around you right now you're surrounded by objects next to me i have a microphone a monitor a mouse and a cup of coffee so we can use code to mimic real world objects objects can have fields and methods these are defining characteristics and actions that an object can perform they describe what an object has and what an object can do and in today's video we will be instantiating human objects but will need the help of a human class as a type of blueprint to design what sorts of fields and methods that all humans should have so outside of our class program you can either do this within the same c-sharp file or a separate one within your solution explorer i'll keep it all within the same c-sharp file this time let's create a class named human then curly braces so let's add some fields fields are kind of like the defining attributes of what all humans should have let's say that humans have a name and an age so i'll define those much like what we do with variables string name i will declare this but not yet assign it as well as int edge so these are fields they're defining characteristics of what an object has now let's create some methods what kinds of actions can humans perform they can eat and they can sleep void eat and then i will display something when we invoke this method let's say name plus is eating and then let's create a sleep method void sleep name plus is sleeping okay now this is what we need to do to instantiate an object from a class type the name of the class human we need a unique name for this human object let's call this human object just human one human human one equals new human again add a set of parentheses and a semicolon there we go we now have a human object named human one now there's just one problem the fields and methods of this human object are not visible so if i type human one dot we can't access the name and age fields as well as the eat and sleep methods so normally i wouldn't recommend doing this because this isn't secure but just for learning purposes let's precede our fields and methods with the axis modifier of public so that these are publicly accessible from another class so if we type human one dot we should be able to access our name and age fields as well as the eat and sleep methods so let's give humanoid a name human1.name and let's assign human1 a first name of rick like from rick and morty and let's give him an age too human one dot h and he will be 65 years old and we should be able to use the eat and sleep methods now humanone dot eat and then human one dot sleep so after invoking these two methods eat and sleep this will display rick is eating and rick is sleeping so congratulations we have successfully instantiated a human object and the nice thing about classes is that we can keep on using this class to create more humans if we need more than one so this time let's create a second human so follow this formula the name of the class human then we need a unique name for this human object human one is taken so let's name the second human human to equals new human and then we can assign some of the fields of our human class so we need a name and an age so human 2's name will be morty and his age will be 16 and this time let's have human 2 use the eat and sleep method so rick is eating rick is sleeping morty is eating morty is sleeping so that's basically what an object is it's an instance of a class and a class can be used as a blueprint to create objects and objects can have fields and methods fields are what an object has methods are what an object can do think of it that way so yeah those are objects they're an instance of a class and a class can be used as a blueprint to create objects so if this video helped you out help me out by smashing that like button leave a random comment down below and as always subscribe if you'd like to become a fellow bro all right constructors a constructor is a special method found within a class it has the same name as the class name in the last video we created a human class but it's missing a constructor if we do not explicitly create a constructor there is a hidden one behind the scenes that is automatically called and it is used to create an object for us so let's explicitly create a constructor so you type public because we want this to be publicly accessible and then it has the same name as the class name then add a side of parentheses then a set of curly braces this works just like a method and we can even set up parameters so let's set up name and age parameters so we need to list the data type string name and int edge now in order to create a human object we have to pass a matching set of arguments we need to pass in a name and an age well a string to function as a name and an integer to function as an edge so we don't manually need to assign these fields anymore we can just pass these values as arguments so with human one human one's name was rick and his age was 65 so i will pass these as arguments rick and 65 and you can see that that red underline went away so let's do the same thing for human too morty and his age 16 and we no longer need to manually assign those fields however within the constructor we'll need to do so so type this dot the name of the field we would like to assign equals the name of the parameter and in this case they have the same name this dot name equals name and this dot age equals whatever this is age and this will work the same as before but we did not need to manually assign those values to those fields so after calling the eaton sleep method for both human one and human too this will display rick is eating rick is sleeping morty is eating morty's sleeping so that's kind of what a constructor is it's a special method found within a class and it's automatically called when we instantiate an object if we do not explicitly create a constructor but if we do we can manually assign some values to fields of an object let's try a different example this time instead of humans let's create a car class we will instantiate some car objects so let's delete our current class and create a new one class car then curly braces cars will have let's say four fields a make a model a year and a color string make string model int year and string color then to create a constructor this will have the same name as the class name precede this with public car parentheses curly braces and again this is a special kind of method and we can set up arguments and parameters so we have string make string model integer and string color and then when we receive arguments we can assign them to these fields this dot make equals make this dot model equals model this dot year equals year and this dot color equals color then let's create maybe a drive method public void drive and we will display something u drive the plus make plus a lot of space to separate make and model plus model okay now let's instantiate some car objects so we type the name of the class car then we need a unique name or identifier for this car let's call this first car car one equals new car parenthesis semicolon but to instantiate a car object we have to pass a matching set of arguments to these parameters we have to pass a make model year and color so car one let's say is a ford mustang ford mustang the year will be 2022 and the color is red and then let's have car one use the drive method so type car one dot drive then a set of parentheses to invoke it u drive the ford mustang now let's create cartoon it's the same process as before but we need a unique name or identifier car car 2 equals new car this will be a chevy corvette and the year will be 20 21 and the color is blue and then let's use the drive method of car 2 car 2 drive you drive the ford mustang you drive the chevy corvette so yeah that's a constructor it's a special method found within a class and it has the same name as the class name class car and the constructor name is car as well and it can be used to assign arguments to fields when creating an object there's a few other things you can do with constructors too but we'll discuss that in future videos so yeah those are constructors if you can smash that like button leave a random comment down below and well yeah those are constructors in c sharp oh yeah let's do this all right the static modifier the static modifier is used to declare a static member one which belongs to the class itself rather than any one specific object i have a class named carr cars have a field named model and a constructor to assign a model when we instantiate a car object and i have two car objects car one and car two car one is a mustang car two is a corvette here's the situation let's say that we're going to have a race but we need to keep track of how many cars are instantiated that are entering our race one way in which we can do that is to create a static field to keep track of how many cars are created so let me show you what this looks like with a non-static field first so let's declare an integer variable named number of cars to keep track of how many cars we create so i will declare this but not yet assign it and within my constructor i will increment number of cars by one remember that with constructors you're not limited to only assigning values to fields you can do like any sort of code that you want remember that it's just another kind of method okay so every time we instantiate a car object we will increment number of cars by one and then let's display a number of cars so we need to access this in a non-static way by typing the name of a car object like car 1 dot followed by the name of the field but it looks like we need to make this public public and number of cars car one dot number of cars let's do the same thing for car two car two dot number of cars now you would think that the number of cars would be two right and that's where you're wrong number of cars for both car 1 and car 2 are both one because each car object has their own copy of the number of cars field and within the constructor when we increment each copy of number of cars well it's only ever going to be a maximum of one so one way in which we could fix that is to change this field to a static field after public type static public static int number of cars and we can no longer access this field in a non-static way by typing the name of an object followed by the name of the field we would have to access this field in a static way by typing the name of its class followed by the name of the field so type the name of the class car followed by you know dot then the name of the field so this field now belongs to the car class and no one object has complete ownership of it it's kind of like they're all sharing the same variable and let's try this again so the number of cars that we have created is two now just to test everything let's create a third car we have a third racer within our race so car 3 will be a what about a lambo and we now have created three cars so again by preceding this field with the static modifier the class now owns it we can also apply the static modifier to a method as well public static and we'll create a method to begin our race let's call this start race so we don't want each object to be able to start the race on their own terms right so it would be better if the car class itself has a start race method so then if we would like to begin our race we can access it in a static way the race has begun then if i need to invoke this method i type the name of the class car dot the name of the static method start race then a set of parentheses to invoke it and this should now begin our race the race has begun and then you can also apply the static modifier to a class itself but then you can't instantiate objects from this class you can see that we're getting errors cannot declare a variable of static type cart so that's kind of like the deal with the math class in order to use a method of the math class we wouldn't create like a map object right like math math 1 equals new math right and then we wouldn't type math1 dot round to rounded number it's a lot easier just to use directly the math class and type math dot round so that's kind of the idea behind a static class you can't create objects from a static class and we kind of learned about that in the video on classes well in conclusion the static modifier can be applied to a field a method or a class itself anything that is declared static now belongs to the class and no one object has ownership of it so that is the static modifier if this video helped you out help me out by smashing that like button drop a random comment down below and well yeah that's the static modifier in c-sharp all right overloaded constructors by using overloaded constructors this is a technique to create multiple constructors within the same class much like that video on overloaded methods so with overloaded constructors multiple constructors can have the same name but they need a different set of parameters because a method's name plus its parameters equals a unique method signature and each method must have their own unique signature so let's create a class named pizza and there's going to be four fields let's have string bread for the type of bread we would like for our pizza like is it flat bread stuffed crust plain a field for sauce cheese and topping then let's create a constructor public pizza and then we need to set up the parameters string bread string sauce string cheese and string topping and then we'll need to assign these this dot bread equals bread this dot sauce equals sauce this dot cheese equals cheese and this dot topping equals topping all right then let's construct a pizza object pizza let's call this pizza all lower case equals new pizza then we need to pass in something for the bread the sauce the cheese and the topping because we can't construct a pizza object without bread sauce cheese and a topping we need all four in order to construct a pizza object so let's pass in something for the bread let's say i would like a stuffed crust pizza stuffed crust for the sauce let's say red sauce and the cheese what about mozzarella i don't remember how to spell mozzarella mozzarella i'm taking a guess here and a topping pepperoni so we can construct a pizza object just fine right but what if we would like a pizza without any toppings like a plain cheese pizza so i'm going to get rid of that topping well we can't construct a pizza without a topping we need to add something because we only have one constructor set up and we need to pass in something for a topping so one way in which we can solve this problem is to have multiple constructors overloaded constructors we can pass in a varying amount of arguments so if we would like a cheese pizza without any toppings we can use that specific constructor that will construct a plain cheese pizza so let's copy this constructor they can have the same name but they need a different set of parameters so i'm going to remove this topping parameter and we will not assign this dot topping equals topping and we can now create a plain cheese pizza and let's do the same thing with i don't know maybe somebody doesn't want cheese on their pizza so pizza with only bread and sauce and then another pizza with only bread i'm not even really sure if it's considered a pizza then maybe it's garlic bread or something but i don't know though we can now create a pizza object that has no toppings no cheese and no sauce so by using overload constructors we can construct objects with varying amounts of fields maybe we would like toppings maybe we don't well we have a choice now so yeah that's overloaded constructors it's a technique to create multiple constructors with a different set of parameters they can share the same name but you need a different set of parameters because a constructor's name plus its parameters equals a constructor's signature and each constructor needs a unique signature so yeah those are overloaded constructors in c sharp if this video helped you out help me out by smashing that like button leave a random comment down below and well yeah those are overloaded constructors in c sharp all right what's going on people inheritance so inheritance is this programming concept of one or more child classes receiving fields methods etc from a common parent kind of like how people inherit genes from their parents well with programming we can kind of do something similar parent classes can have children classes and anything that the parent class has the child classes now have so here's an example let's create a parent class named vehicle not any kind of specific vehicle just a generic vehicle class class vehicle and there will be one field let's say public and speed and i'll set this equal to maybe zero and let's create a method public void go all vehicles can go somewhere and all we'll display is this vehicle is moving we can inherit this speed field and this go method from the vehicle class so this vehicle class is going to have children so let's create a car class a bike class and a boat class so type class car then to inherit from another class type after the class name colon and then the parent in which you would like to inherit from so car is going to be the child class vehicle will be the parent class so car will have access to its own speed and go method and then you can add anything additional within the car class like number of wheels public and wheels and i'll set this to 4 for all car objects now let's create a bicycle class it's the same process as before class bicycle and this will inherit from the vehicle class as well but let's change wheels to two and then let's create a book class class boat and here it's from vehicle wheels zero because well it's a boat okay so let's instantiate a car bicycle and boat object so let's do that here car car equals new car bicycle bicycle keep on spilling bicycle wrong bicycle equals new bicycle and boat boat equals new boat so if we take a look at this car object car dot there is a speed field as well as a go method even though there's nothing within this car class besides wheels so since car is the child class and vehicle is the parent class car has access to a go method and a speed field even though there's nothing within here except a wheels field and of course car objects do have a wheels field as well which we stand within the car class so let's just test these i'm going to display car dot speed car dot speed followed by car dot wheels and i will have this car use its go method car.go all right so our car speed is zero that's because we set it to be zero within the vehicle class this car has four wheels which we stated within the car class and this car class has a go method that states this vehicle is moving so i bet the same thing applies to our bicycle and boat object so let's copy these three lines of code change car to bicycle bicycle.speed bicycle.wheels and bicycle.go and the same thing applies to both boat dot speed boat dot wheels boat dot go so all three of these different types of vehicles each have a speed field a wheels field and a go method so the point of inheritance is that we can reuse code i mean we could just copy these fields and methods and then paste them within each of these classes but imagine that you have hundreds of different classes and we need to change like go to start well it's a lot easier just to make that change in one place than having to manually go through all of our classes so yeah that's kind of the benefit of inheritance we can keep anything that these classes have in common within a common parent class and these classes can simply just inherit these fields and methods so yeah that's inheritance if you liked this video be sure to smash that like button drop a random comment down below and well yeah that's inheritance in c sharp alright what's going on abstract classes abstract is a keyword that we can apply to classes properties and methods but in this video we're going to focus on abstract classes now you can apply the abstract keyword it's a modifier to a class and that indicates that this class is missing components or is an incomplete implementation so let's take a look we're using inheritance here so i have a class vehicle vehicle has a speed field as well as a go method and there's three children classes car bicycle and boat and these are complete implementations so car has four wheels and a max speed of 500 bicycle has two wheels a max speed of 50 and boat has zero wheels and a max speed of 100 i just made up some numbers for the max speed i can create a car object bicycle object and boat object just fine these are complete implementations but unfortunately i can also create a vehicle object vehicle vehicle equals new vehicle so vehicle is incomplete it's missing a number of wheels and a max speed so imagine that we're having a race and somebody decides to pick the vehicle but we want somebody to pick a specific implementation of a vehicle like a car bicycle or boat i would like to prevent people from creating generic vehicle objects so this is kind of like imagine somebody picks the invisible vehicle in like a racing game or something one way in which i can prevent people from instantiating vehicle objects because it's not finished it's an incomplete implementation is to precede this class definition with this abstract keyword so if i precede class with abstract i can no longer create a vehicle object cannot create an instance of the abstract type or interface vehicle so that adds a little bit of security to our programs if there's a class that you do not want to be able to instantiate objects from you can just precede that class definition with the abstract keyword and you cannot create an object from that class and that's basically what the abstract modifier does we can indicate that a class we can also apply this to properties and methods as well but that's a video for another day so when we precede a class definition with abstract we are indicating that that class is missing components or is incomplete so we should not be able to instantiate objects from this class which adds a little bit of security so yeah that's the abstract keyword if you found this video helpful help me out by smashing that like button leave a random comment down below and well yeah that's the abstract modifier in c-sharp all right what's going on people so in this video i'm going to show you all how we can create an array of objects i have a class car cars have one field a model field and a constructor to assign an argument to this model field so let's create some car objects car car one equals new car then pass in a model of your choosing let's say that car one will be a mustang and let's create maybe two more cars car two and car three car two will be a corvette and car three will be a lambo so we'll need an array to work with too so in the past when we've created arrays we will list the data type of what we're storing within our array like strings ins whatever so after the data type add a set of straight brackets but the data type is going to be the data type of the objects that we're working with since we're working with car objects we'll change that to car car straight brackets then we need a name for this array let's say garage it's kind of like we're parking cars within a garage equals new the data type again straight brackets then a size for this array let's say three then we will assign some of these indexes with an object so let's begin with garage at index zero this will equal let's say car one it's as if car one is parking within our garage at this parking spot number of zero then let's park car two and car three so garage at index of one equals car two garage at index of two equals car three then let's display these console.right console.writeline garage at index of zero so let me just show you what this looks like first we're not accessing the model quite yet we're just displaying whatever's within garage at index of zero and what we get is the namespace followed by the data type of our object so if we need the model of this object whatever's within garage index of zero i'm going to follow this with dot model and that will display my car's model which is a mustang then let's do the same thing for garage at index of one and two so garage index of one garage index of two then make sure to follow those with dot model so within our garage between indexes 0 through 2 we have a mustang corvette and a lambo now another way in which we could display these is with a for each loop for each parentheses curly braces and with our for each loop we have to list the data type of whatever's within our array car and let's call each car just car car car in garage then during each iteration we will display car dot model and that will do the same thing however this time we will iterate through our array now there's another way in which we could write this too we don't need to necessarily define a size for our array then create some named car objects and then assign those objects directly to each index we could just declare an array and then immediately instantiate some objects all in one step so we're going to create a new array car straight brackets i will call this garage equals curly braces and then we will pass in just new car then you need to pass in a model and do the same thing with your other two cars okay this will do the same thing it's just written in less steps so these are known as anonymous objects they don't technically have a name so i may or may not make a separate video on anonymous objects so within our garage we should have a mustang corvette and a lambo so yeah that's how to create an array of objects in c sharp hey what's going on people in this video i'm going to show you all how we can pass an object as an argument so here's the rundown i have a class car cars have two fields a model and a color and a constructor to assign a model and color argument that we receive i have one car object car car one equals new car the model of this car is a mustang and the color is red so i'm going to create a method that will change the color of my car but i have to pass in a car object so let's create a method to handle that for us public static void it's not returning anything and let's call this method change color and we'll need two parameters a car that we would like to change the color of so the data type is going to be car as well as a name for this parameter let's name whatever car object that we receive as just simply car and we need a color as well that would be a string string color then to change the color of this car i would type car dot color equals whatever color that we receive and that's it so now when we invoke this method we have to pass in a car object as well as a color so that would be change color and the car object that i will pass in as an argument is car 1 the name of the object as well as a new color let's color this car silver and then let's display our cars color and model console.right car one dot color plus a lot of space plus car one dot model and this should change the color of our car to a silver mustang so to pass an object as an argument you need to make sure that you have the right parameter set up you type the data type of this object followed by a name for this parameter then when you invoke this method you have to pass in the name of the object let's try something a little bit different let's create a method to copy an object so let's get rid of this change color method but we'll keep our car object so we'll create a method to return a car object so public static instead of void the data type is the type that we're returning we're returning a car object so replace void with car then we need a name for this method let's call this copy so we will pass in a car object the data type is car and i will name this argument that we receive as car now one thing that we can do to copy a car object is return a new car and then we'll need to pass in a model and a color so the model of this car is car dot model and the color is car dot color now if i would like to copy car 1 and create a second car a copy of it i can type car car 2 equals copy and then i will pass this object as an argument and then let's display the fields of car2 and i bet it's a red mustang oh yeah there we go so we successfully created a copy of car one by returning a car object so yeah that's how to pass objects as arguments you just have to list the data type of the object since we're working with cars we had to set up a cart parameter then if you would like to return an object instead of void you would replace void with the data type of the object you would like to return and if you would like to return a new object like what we did with this copy method you would return a new and then call the constructor of whatever object you would like to create and return so that's why we called the car constructor and then we returned that new car back to this spot here so it's kind of like we replaced this method with calling the car constructor something like that so yeah that's how to pass objects as arguments as well as return objects from methods too so yeah if this video helped you out feel free to help me out by smashing that like button leave a random comment down below and subscribe if you'd like to become a fellow bro right what's going on people we're talking about method overriding method overriding provides a new version of a method inherited from a parent class i have a class animal this is a parent class also known as a super class or base class and i have two child classes dog inherits from animal and cat inherits from animal so let's say that we have a method within our animal class so let's create one public void speak all animals can speak and then when a class that inherits this method uses this method let's display a message such as the animal goes okay let's create a dog object and a cat object dog dog equals new dog cat cat equals new cat dogs since they're inheriting from the animal class they have a speak method as well as cats cat dot speak so when both this dog object and this cat object invoke their speak methods that they inherit from the parent class of animal we will execute this method and when my dog and cat object speak that will display the animal goes burr okay so we can actually provide our own implementation of this method we can override this method and do something else now to overwrite a method it needs the same method signature the same name and the same parameters so if i would like to override this speak method within my dog class i'm going to type public override void the same type as the original method and the same name and signature now to create an overriding method the method that is inherited must be virtual abstract or already overridden so i'm going to add this modifier virtual so we can now override this method you can also do this with an abstract method too but the class needs to be abstract as well and there needs to be no body but we'll just stick with virtual in this video okay so we have our virtual method that means that this method can be overridden and now we can provide our own implementation of the speak method specifically for dogs so let's display a different message console.rightline the dog goes woof so notice that we don't have anything within our cat class now if both dog and cat use their speak methods the dog will instead speak and say the dog goes woof and our cat is still using the method that inherits from its parent animal if i would like to do the same thing for my cat objects i can override this method again public override void speak and then i can provide a different implementation the cat goes meow so after both dog and cat use their speak methods this displays the dog goes woof the cat goes meow so by using method overriding we can provide a new version of a method inherited from a parent class however the inheritance method must be abstract virtual or already overwritten and a method overriding is commonly used with the tostring method which we still need to talk about and polymorphism so yeah that's method overriding if you found this video helpful please smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro all right welcome back everybody the two string method the two string method is an inherent method of objects its job is to convert an object to its string representation so that it is suitable for display so i have a class car cars have four fields i make a model a year and a color and i have a constructor to assign some of these fields so what we could do if we would like some of this information we can override the built-in tostring method of objects that includes cars 2. so let's create a car object car car equals new card then i need to pass in a make model year and color let's say that this is a chevy corvette the year is 2022 and the color is blue so within a writeline statement if i type the name of my object car there's actually a tostring method and when we invoke this method let's take a look to see what happens so this displays the namespace followed by the type of the object that we're working with so we can actually override this method so that when we use the tostring method we can return a string representation of this object maybe we can display the make model year in color somehow so we'll need to override this method to string so let's do that here we're going to type public then to override a method we have to use that override keyword then type to string and this might auto-generate for you so we're returning a string and by default this will return base to string what we can do instead is return something else we can return some sort of string representation that's suitable for display let's say that when i use the tostring method of my car object i'd like to return a sentence that says this is a make plus model a chevy corvette so let's do something like this let's say string message equals this is a plus make then i'll just add a space plus model really you can do whatever you want and then i'm going to return this string or i could take all of this copy it and then return this is a make plus model i could do that too and that would work so when i use the tostring method it's going to return this sentence and insert make and model this is a chevy corvette one thing you can do too you don't necessarily need to directly invoke the tostring method you can just type the name of the object and that will do the same thing so this will behind the scenes called the tostring method so before when we displayed our object with a writeline statement it would display the namespace plus the type of the object but if you were to override the tostring method you can return some sort of sentence or string representation of your object that is suitable for display so yeah that is the tostring method it converts an object to a string representation that is suitable for display and really you can type whatever you want here just be sure to return a string so yeah that is the two string method if you found this video helpful please be sure to give it a thumbs up drop a random comment down below and subscribe if you'd like to become a fellow bro hey what's going on everybody it's you bro hope you're doing well and in this video i'm going to explain to polymorphism in c sharp so sit back relax and enjoy the show all right what's going on people polymorphism polymorphism is a greek word that means to have many forms with programming objects can be identified by more than one type they can have many forms for example let's say that we have a dog a dog could be considered a canine an animal and an organism so a dog has more than just one form it has more than one data type here's the situation we're going to have a race we'll enter in a car object bicycle object and boat object so i have four classes vehicle is the base class otherwise known as the parent class and car bicycle and boat all inherit from the vehicle class so with my race i need to create a car object bicycle object and boat object so let's do that car car equals new car bicycle bicycle equals new bicycle and boat boat equals new boat i would like to place all of these objects within an array for my race but what's the data type of the array going to be so let's try and make an array of cars and add our car bicycle and boat and let's just see what happens i will name this array just vehicles equals and then within curly braces add whatever objects you would like i would like to enter my car into the race my bicycle and my boat okay but we're running into some errors here cannot implicitly convert bicycle to car so i stated that the data type of this array is going to be cars i can only enter car objects so i have no issue there but i cannot enter in my bicycle and boat objects into this array but one way in which we can solve this is by using polymorphism so we can find what they all have in common they all identify as vehicles because they all inherit from the vehicle class these objects have more than one form they can be identified by more than one type so instead of my array being an array of cars i'm going to change this to vehicle because well these three objects identify as well a car a bicycle and a boat respectively but also vehicles because they inherit from the vehicle class so you can see that this is valid if you need to create an array of different types of objects you have to find what they have in common and then you can just use that as a data type they are all also considered vehicles let's move on to part two what i would like to do is have all of these vehicles use a go method so they will all begin the race at the same time so let's create a go method within each of these classes public void go and we'll just display the car is moving place that within the car class let's make a go method for bicycles change car to bicycle and then the boat is moving okay now to iterate over this array of vehicles we can use a for each loop for each now what's the data type of our vehicle array well it's vehicles vehicle vehicle in vehicles and now i would like each vehicle to use its go method vehicle.go so each vehicle will use its go method but there's one more thing that we need to do we need a go method within our vehicle class so all of these methods within our car bicycle and boat classes all are going to be overriding a go method found within the vehicle class so let's create a virtual method public virtual void go and we don't necessarily need to define anything within the go method because we're going to be overriding this method okay then we need to use this override modifier all right now when we iterate over this array of vehicles each vehicle will use its go method it's as if when we would like to begin our race all of the vehicles within our array will use their go methods at the same time the car is moving the bicycle is moving the boat is moving so yeah that's polymorphism it's a greek word that means to have many forms objects can be identified by more than one type and in this example we created an array of vehicles our car identifies as a car but it also identifies as a vehicle and objects do identify as objects too so cars identify as objects and the same thing can apply with bicycle and boats in our example so yeah that's polymorphism if you found this video helpful be sure to smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro all right interfaces an interface is much like a parent class or base class it defines a sort of contract that all classes inheriting from need to follow an interface can contain properties methods events and if there's any of those declared within an interface anything that inherits from that interface needs to be implemented within an inheriting class an interface declares what a class should have and the class that it inherits from defines how it should do it exactly so here's an example we'll create three classes rabbit hawk and fish and two interfaces prey and predator alright now let's create two interfaces to create an interface you type interface and then the name of the interface however a common naming convention with interfaces is that you precede the interface name with capital i so if we would like a prey interface we would type i pray and then let's create a predator interface interface i predator now with these interfaces we can pretty much declare anything within these interfaces but if one of these classes would like to inherit from this interface they need to implement anything declared within them so let's say that if you're prey then you need a method to flee because you're fleeing from predators i'm going to declare a flea method void flee we will declare it but not implement it implementing this method is the job of the inheriting class that would like to use this interface let's say that rabbits will inherit this interface i pray colon i pray and in order to do so we need to implement this method of fleet within the rabbit class in order to use it public void flea and then be sure to add a body to this method so when we invoke this method let's write the rabbit runs away okay now we can create a rabbit object rabbit rabbit equals new rabbit and i bet there's a flea method rabbit dot flea and let's try it the rabbit runs away now let's have our hawk class inherit this predator interface now with our predator interface let's create a method to hunt void hunt we will declare it but not implemented implementing this method is the job of the classes inheriting this interface so hawk will inherit the i predator interface but we need to implement that hunt method public void hunt and then let's display the hawk is searching for food and we can create a hawk object hawk hawk equals new hawk so let's take a look at our hawk object hawk dot and there's no flea method because we're not implementing the prey interface we're implementing the predator interface so there is a hunt method and not a flea method hawk.hunt the hawk is searching for food now with interfaces you can inherit more than one unlike with standard inheritance so fish they could be both prey and predators to inherit two interfaces after the colon you can separate each with a comma so fish will inherit the i prey and i predator interfaces but now they need to implement both of these methods flea and hunt so let's do so public void flea the fish swims away and now we need to implement that hunt method public void hunt the fish is searching for smaller fish all right now let's create a fish object fish fish equals new fish so fish have both a flea and a hunt method fish dot flea fish dot hunt the fish swims away the fish is searching for smaller fish so an interface defines a sort of contract that all classes inheriting from should follow an interface declares what a class should have and the inheritance class defines how it should do it the benefits of using interfaces for one is that you can inherit multiple interfaces unlike with standard inheritance there's added security and this gives us a plug-and-play style of coding because anything that has the same interface will definitely have the same implemented methods and properties so you can swap these out for like a different creature if you would like so yeah those are interfaces if you found this video helpful please be sure to give this video a thumbs up leave a random comment down below and subscribe if you'd like to become a fellow bro all right welcome back everybody a list a list is a data structure that represents a list of objects that can be accessed by index it's similar to an array but they can increase and decrease dynamically in size during runtime which rays cannot do so here's an example of an array an array has a static fixed size and we cannot change it normally after runtime so let's create a standard array just for this example let's create an array of food string food equals new string and let's say that this array has a size of three so i'm going to add some elements to this array and then i can display these elements with a symbol for each loop pizza hamburger and hot dog so if i attempt to add another element to this array this is what happens we'll run into an exception and index out of range exception because index was outside the bounds of the array so you can't normally change the size of an array another option is to use a list a list can increase and decrease dynamically in size during runtime so let's create a list step one is that we'll need to import system.collections.generic so include this at the top i'll place it right underneath using system and this is how to declare a list list then within angle brackets list the type of object you would like to store strings and then i will name this list food equals new list angle brackets the data type again parentheses semicolon and we now have a list named food and to add elements to this list there is a built in add method food dot add then within this method pass in the object you would like to store i would like to store let's say a pizza then a hamburger then a hot dog so food dot add pizza hamburger and hot dog and let's take a look so we have our pizza hamburger and hot dog and i bet we can add even more than three elements so it appears that our list can resize dynamically which is a bonus then to access one of these elements it's much like an array you use that set of straight brackets so i'm going to display whatever's within element number zero food index zero and that would be pizza so accessing an element is the same as an array you just type the list name and then add a set of straight brackets then the index number okay so here's a few other useful methods of lists there is a remove method food dot remove then type in what you would like to remove i would like to remove fries and let's see if that's still in here nope fries is missing pizza hamburger hot dog so that is the add method and remove method but there's a few other useful methods so we can insert an object at a given element let's insert maybe sushi at index 1 via the insert method food dot insert then we need an index and an item so at the beginning of our list at index 0 i will insert sushi sushi pizza hamburger hot dog fries we can get the current size of our array using the count property so within a writeline statement i'm going to display food dot count property and the current size of our list is four so that is the count property we can find the index of an element food dot index of and let's find where pizza is so that is at index zero you can also find the last index of a given item so what if we have fries both in the beginning and at the end food dot add fries so i have that in the beginning and at the end so i'm going to use the last index of method food dot last index of fries and the last index surprise is at four zero one two three four so let me get rid of that okay we can check to see if our list contains a given item using the contains method food dot contains pizza this will return a boolean true if pizza is within our list and false if not pizza is within our list so that returns true and that is the contains method then we have sword food dot sword this will sort our list alphabetically so our list in alphabetical order is fries hamburger hot dog pizza and we can sort in reverse order food.reverse and our list in reverse order is fry's hot dog hamburger pizza we can clear our list food dot clear and now our list is empty and lastly we can convert our list into an array so i'm going to declare a new array string let's say food array equals food dot 2 array string item in food array so we have pizza hamburger hot dog fries well okay then everybody that is a list it's similar to an array it's a data structure that represents a list of objects that can be accessed by index it's similar to an array but they can increase and decrease dynamically in size but they waste more memory so yeah those are lists in c sharp if you found this video helpful please be sure to give it a thumbs up drop a random comment down below and as always subscribe if you'd like to become a fellow bro all right what's going on everybody so in this video i'm going to show you all how we can create a list of objects from a custom class of ours in the last video i showed you all how we can create a list of strings but what if we would like to create a list of players to keep track of the amount of players in our game and their names so let's create a list list then we need angle brackets and the data type of the object we would like to store within our list i would like to store player objects and i'll name this list players because we're keeping track of the players players equals new list angle brackets our data type again player parentheses semicolon so we now have a list that can store player objects so let's instantiate some player objects and i have a field setup username you can also set up getters and setters too if you prefer so let's create some player objects player and we'll call this player player1 equals new player but we need to pass in a username as an argument let's say that this is chad and i'll create maybe two more players so player one player two player three player two will be what about steve and karen okay now to add our player objects to our list type the name of the list dot add and then pass in the name of the object players dot add player 1 then do the same thing with player 2 and player 3. then i'll use a for each loop to display all these for each the data type is player player in players so let's take a look at this i'm going to console.writeline each player but since we're displaying each object directly what's going to be displayed is the namespace plus the data type of our object we can access the username field and that will display each player's username or we can overwrite the tostring method so we have chad steve and kieran or we can override the tostring method so let's try that too public override to string and i'm going to return username so then when i use console.writeline i can just type in the object's name so we have chad steve and karen now another thing that you can do when we instantiate these player objects we can do so anonymously so within the add method of our list players we can simply just pass in new player then pass in a name and then we don't necessarily need to create a name for each of these objects so i'm going to pass in new player steve and new player karen so this is optional but i like to create anonymous objects it's less work so we should have our three players chad steve and karen so yeah that's how to add objects to a list within the angle brackets you just list the type of object that you would like to store within your list so yeah that's a list of objects in c sharp if you found this video helpful please be sure to smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro all right we have a lot to talk about today getters and setters but before i explain what these are let me explain the situation we have a class car and we have one field within our car class speed so when we construct a car object we need to pass in something for the speed maybe this is miles per hour kilometers per hour doesn't really matter so let's say that somebody takes our car object and changes the speed to like whatever this number is 100 million actually let's make that a billion how can we prevent people from doing this because currently our car is going way too fast so one way in which we could do that is to change this field from public to private but then we can't access it at all another way is to set up getters and setters and this adds security to our program via this concept called encapsulation so we need to first set up a property for this field the property name is the same as the field name except it's capital so type public if you're returning something list the data type then speed and then let's make this capital then add a set of curly braces a property combines the aspects of both fields and methods and it shares the same name with the field so it's kind of like something in between a field and a method and it contains accessors a get and set accessor now to first assign a value we'll need to change our constructor instead of assigning the field speed we will assign the property speed so this has a capital s let's create a get accessor first when we would like to get the value of speed whatever is contained within speed we will use this get accessor so type get curly braces and we will return speed and then we'll need to assign this with the set accessor then make sure you have that semicolon at the end so by using this get accessor this will read whatever value is within our field then we'll need a set accessor if we would like this to be writable set curly braces so what we'll do here is set speed equal to value so value is kind of like a parameter properties combine the aspects of both fields and methods so when we assign a value to speed well then this value is going to be this so it's kind of like an argument and a parameter and within our set accessor we can actually set up like some code or some rules or something so if somebody attempts to change the speed we could write an if statement like if value is greater than let's say 500 then we will limit this let's change speed equal to 500 then else speed equals value now car.speed is inaccessible due to its protection level so we need to access instead of the field the property so that's speed with a capital s and then if we're going to display the value of speed we'll access the property instead of the field so if we attempt to set our speed equal to 1 billion well we will access this set accessor and then it's going to be limited to 500 then so if we attempt to change our speed to 1 billion it will be limited to 500 and then we can still display the value and access it because by having a getter and setter this is both readable and writable so yeah those are getters and setters they are accessors found within a property a property combines the aspect of both fields and methods and if you have a private field you can also set up a property that has getters and setters for more security so yeah those are getters and setters in c sharp all right everybody we have to talk about auto implemented properties this is an intimidating name but don't worry it's actually fairly simple they are shortcuts when no additional logic is required within a property you do not have to define a field for a property and you only have to write get and or set inside the property here's an example i have a class car and what if we would like a model field and property so that might look something like this make sure to not make your field public for this example so this will be a string named model for a model of car and i would like to set up a property that has get and set accessors so that would be public string model with a capital m curly braces and then i need a get and set accessor all we'll do within the get accessor is return model and that's the field and a set will be model r field equals value and within my constructor i will set this dot model property make sure that you have capital m equals model whatever our parameter is so if you're not doing anything else within your getter and setter there's actually a shortcut to all of this and that's by using an auto implement property so this is what we'll do we're going to instead get rid of all this and type public string model with a capital m curly braces get semicolon set semicolon and this will do the same thing however it's a lot less to write so if there's no additional logic that you need besides you know setting the value and getting the current field well you can just use an auto implemented property and this will do the same thing let's test it so let's create a car object car car equals new car then pass in a model of car let's say a porsche this time and then i would like to display the car's model car dot model property with a capital m so there will still be a model field but it's hidden and this car's model is a porsche so that's like a shortcut you can do an auto implemented property is a shortcut when no additional logic is required in the property you do not have to define a field for a property and you only have to write get and or set inside the property so yeah that is an auto implemented property if you liked this video please give it a thumbs up drop a random comment down below and subscribe if you'd like to become a fellow bro all right what's going on people enums enums are a special kind of class that contains a grouping of named integer constants we tend to use enums when we have values that we know will not change so here's an example let's create an enum of planets and we will associate a planet number with each named planet so to create an enum type enum then a unique name kind of like we're creating a class then curly braces so i'm going to add the name of each planet within our solar system beginning with mercury and then separate each with a comma so we have mercury venus earth then just continue on in this pattern this isn't necessary but i like to place each of my members on a new line within an enum i think it's easier to read okay we now have an enum of planets and there's an associated integer with each of these members if we do not explicitly set an integer by default the first member is zero then one two three then you just follow that pattern so let's access one of these members of our enum of planets let's display a message planets dot pluto is a planet so taxes a name of one of these members you type the name of your enum planets dot the name of your named member pluto this will return the name not the integer let's try it pluto is a planet this is no different from using the two string method this will do the same thing pluto is a planet okay now if we need the associated integer with each of these named members we would cast this member as an integer let's change our message around let's say that planets.mercury is planet number than to access one of the integers stored within a member that would be planets dot the name of a planet mercury and then we will precede this with parentheses and this will convert our named member into an integer so our message is now mercury is planet number zero so these named members always begin with zero but we can change that and set them let's say that mercury equals one venus equals two and then continue on in this pattern let's display pluto as well because pluto is feeling left out planets dot pluto is planet number planets dot pluto then cast as an integer okay mercury is planet number one pluto is planet number nine let's try something a little bit more complex let's create an enum to keep track of the radius of each planet enum planet radius and let me just copy this okay here's the radius of each planet in kilometers mercury is two four three nine six zero five one for venus and then i'll just fast forward the footage you can copy this down if you'd like all right we have the radius and kilometers of each planet so these are in name integer pairs let's create a variable to store the name of one of our planets string name equals what about earth planet radius the name of our enum dot the name of our member earth so if we're going to store this within a string variable we need to use the to string method and then let's display this just to test it let's say planet colon space plus name and this should display just earth planet earth okay let's get the radius of earth int radius planetradius dot earth then cast this as an integer console.rightline let's say radius colon space plus radius radius 6371 let me add kilometers so that's kind of the nice thing about enums is that we don't necessarily need to remember all of these numbers it's kind of like restoring variables so to say they are name integer constants that will not change through the life of a program now let's move on to a challenge round let's create a method that will calculate the volume of one of our planets when we pass in a radius public static will return a double and this will be the volume method and there is one parameter the parameter is planet radius and we will name this just radius okay we need to return let's say volume and double volume equals and here's the formula to calculate the volume of a sphere 4.0 divided by 3.0 times math dot pi times our radius to the power of three so we can use math dot power pass in our radius make sure to cast this as an integer to the power of three and let's call the volume method and store this within a double named volume double volume equals we will invoke the volume method and pass in planet radius dot earth and then we'll display the volume console.writeline volume colon space plus volume and i think that's in cubed kilometers all right and the volume of earth is whatever number this is one zero eight three something something something something cubed kilometers so yeah those are enums they're like a special class that contains a set or grouping of named integer constants we tend to use enums when we have values that we know will not change and to get the integer value from an item you must explicitly convert it to an integer so yeah those are enums if you found this video helpful please be sure to smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro if you wouldn't mind please like comment and subscribe one like equals one prayer for the youtube algorithm uh generics all right let's get started generics anything that's generic is not specific to any particular data type we can make something generic by adding a set of angle brackets then t we can make classes generic methods fields whatever we want this allows for greater code reusability for different data types let's say that we have three different types of arrays an array of integers doubles and strings let's create those int array i'll call this interray equals i don't know one two three the elements really aren't important the data type is okay then let's say we have an array of doubles i will name this double array and the elements are 1.0 2.0 and 3.0 then let's say that we have an array of strings string array equals one two and three okay what if i would like to display the elements of each of these arrays so we can use a method for that let's begin with a method to accept an array of integers so let's add that here public static void we're not returning anything and let's say that this method is named display elements so there is one parameter if we're displaying an array of integers well that will be our parameter int array and let's call this array and then we'll need a for loop or for each loop to iterate over the elements of this array let's use a for each loop for each int item in array then we will write preferably not right line item then maybe i'll add a space okay let's call the display elements method that we just created and then pass in our interray as an argument and let's see what happens okay we have the numbers one two three so what if we attempt to pass in our double array display elements then we will pass in our array of doubles so we actually can't use this method for doubles we can only use this for integers cannot convert from double to int if i would like to display my array of doubles well i would need a completely different method that accepts an array of doubles as an argument so i'm going to copy this current method that we have change into double and change into double here as well and then we can call this version of our display elements method this will do the same thing actually let me make one change i'm just going to add a right line to the end of these so basically we have two methods that do the exact same thing however they accept a different data type as an argument let's add one more method for strings public static void display elements the parameter is an array of strings for each string item in array and then i can use the string version of display elements but pass in our string array so we have each of our three different types of arrays all displayed so this is a lot of work we have three methods that do basically the same thing however they accept different arguments so what if we had one method that could accept basically any data type well that's where generics come in so let's take these first two methods and delete them we will no longer need them we're going to turn this method into a generic method so after the method name add a set of angle brackets then add t so really you can put anything you want between these angle brackets i like to say thing because i think it's funny we're going to accept a thing as an argument so we need to change that here as well so change any instance of a data type to t or thing if you're using thing okay so change string to thing we're accepting an array of things for each thing item in array so now we have one method that accepts all data types we can reuse this one method for an array of integers doubles and strings and it appears to work so that's where generics are helpful anything that's generic is not specific to a particular data type we can add angle brackets t or really anything within these angle brackets just make sure that it's consistent so we can add this to classes methods fields etc and this allows for greater code reusability for different data types so instead of three different methods that all accept different data types we have one that accepts basically all data types so yeah those are generics if you found this video helpful be sure to smash that like button leave a random comment down below and subscribe if you'd like to become a fellow bro hey what's going on everybody it's bro hope you're doing well and in this video i'm going to explain a multi-threading in c-sharp so sit back relax and well enjoy the show if you find this video helpful please remember to like comment and subscribe your support will help keep this channel running all right all right all right threads a thread is an execution path of a program we can use multiple threads to perform different tasks of our program at the same time so when we begin a program we have one thread that is running and that is named the main thread twerk with threading include at the top using system dot threading so let's get the current main thread that is running and i'll assign this to a local variable of the thread data type let's say thread main thread equals thread dot current thread so this will assign the current thread that is running to a local variable named main thread or whatever you want to name it so i'm going to change the name property of main thread to equal let's say main thread and then i'll display this with a rightline statement main thread dot name and the name of this thread is main thread here's our job let's say that we need two timers to run one is counting up from zero to ten and the other is counting from ten to zero one is counting up the other is counting down but we need both of these timers to run concurrently so if we were to write these both on the same thread this is what this would look like and then later on we'll have these timers run on different threads so let's create a countdown and count up method public static void count down and then i'll need a for loop to iterate 10 times 4 and i equals 10 then i will continue this as long as i is greater than or equal to zero and then decrement i by one during each iteration and during each iteration let's say that timer number one colon space plus i plus seconds now we can actually have our current thread that is running sleep for a given amount of milliseconds by typing thread dot sleep then pass in how many milliseconds you would like your thread to sleep so 1000 milliseconds for one second and then when we escape our for loop let's display that timer number one is complete and we'll also need a count up method so let's copy countdown paste it change down to up i is equal to zero we will continue this as long as i is less than or equal to ten increment i by one during each iteration timer number two timer number two is complete so let's invoke both countdown and count up so remember that these are both running on the same thread our main thread and when we complete our main thread let's display that main thread dot name plus is complete and i'm just going to hide this line here okay let's go so we have timer number one that's running currently timer number two has not started yet because these are both running on the same thread so timer number one is complete and now we're working on timer number two and now timer number two is complete our main thread is complete so if i would like both of these methods to execute at the same time i would need to create some additional threads and here's how to do so thread let's name this thread 1 equals new thread and within the constructor of our thread let's pass in the method we would like to execute thread one is in charge of counting down and thread two is in charge of counting up so each of these threads has a built-in start method which we need to invoke to begin each of these threads thread1.start and thread2.start and we can get rid of these we now have one thread in charge of counting down and the other thread is in charge of counting up and our main thread is still running in the background so our main thread is complete and we have one timer that's counting down and the other that is counting up and as you can see these are both running at the same time concurrently so if you have a method that has parameters there's one additional step let's say that we have i don't know a string name or something we don't necessarily need to use these okay so we can't use these as they are currently so what we're going to do is within the constructor of our threads is pass in what is known as a lambda expression so parentheses arrow then the name of our method countdown parentheses then any arguments if there are any let's say i don't know timer number one i probably won't use this at all but this is just for an example okay let's do the same thing with thread two so we have a lambda expression parenthesis arrow and this is in charge of counting up and passing i don't know timer number two i guess i might have to make a separate video on lambda expressions okay let's try this again so this should work all right there we go so yeah those are threads a thread is an execution path of a program we can use multiple threads to perform different tasks of our program at the same time when we begin a program we have one thread that is running and that is referred to as the main thread so yeah that's multi-threading in c sharp if you would like a copy of this code i will post this to the comment section down below and well yeah that's multithreading in c sharp hey you yeah i'm talking to you if you learned something new then help me help you in three easy steps by smashing that like button drop a comment down below and subscribe if you'd like to become a fellow bro [Music] you