Learn C# with CSharpFritz - Ep 4: C# Conditionals and Loops for Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] there we go good morning good afternoon good evening whatever time it might be where you are out there welcome back to the live stream this is the visual studio channel my name is jeff fritz and welcome back to episode four of c sharp with c sharp fritz this is a very beginner friendly talk show formatted training session right where we're going to teach you all about getting started with c sharp with a whole whole a big big a wide selection of interactive tutorials um q a that we're going to be doing here live on twitch and if you're watching the recording sorry you missed it but we're going to cover all the questions that folks have throughout the stream and you're going to see links to them in the description below along with links to our interactive notebooks and to our github repository for this show we want to make sure that everybody has access to all the material and you can follow up and i will answer all kinds of questions not just here live but also in the comments below if you're watching the recording so i'm i'm seeing that my green screen is is having some fun with my uh with my glasses here today let me say hello to a couple friends that are here in the chat room let's take a look over there hello hello let's say hello to excite is here nat sack is here amy bill chief mufana blue hello everybody's doing well here thank you black eye hello and phone my att is here lacks one hello to you stelzi is here so good to see you some of our friends back for another episode and today today i want to talk about i want to talk about conditional um conditional statements we've been building on our learning here about c sharp we defined types we talked about building building classes declaring variables but this time let's let's start writing some of those basic things that you do with code let's write some conditional statements let's write some loops and do that some of that basic interaction that you expect to see with your code that you're going to do to to make decisions to repeat processes over and over again and we'll have um we'll have some fun along the way and maybe you'll learn a thing or two as we're going to get into some of the more advanced features some of the more advanced let me let me couch that let me retract that get into some of the newer features of the programming language including a little bit of pattern matching i don't want to dive too far into it but just enough to show you what it's capable of top fuel hello to hello to you shai sharp good to see you phonemy att asks if i prefer jeff or fritz my friends call me fritz all right there you go and my kids friends call me mr fritz see how that works see that's a thing um adderson angel good to see you hello adrienne is that adrian help me out with pronouncing that hello hello musicalbookworm is here good morning to you so i want to make sure um yeah that we have a good time here and and we write some code and everybody has an opportunity to ask questions and you'll even see the questions pop up right over here as we go through um as we go through our discussion today that reminds me i forgot to launch the uh the featured chat is the tool that we use in order to present those questions live here on stream i'm just going to get that booted up so that we can keep an eye on chat and i can pop messages in there right away and as well i'm gonna get some music started here in the background um this is stream beats from our friend harris heller and this is uh from a playlist called synth wave and this is intended to be some music that's that that's tech that's a little bit um a little bit groovy that we can listen to in the background this is music that is copyright free available for folks to use on streaming youtube videos and just have as background music without any kind of concerns from uh from wright's holders so i'm gonna start some of that plane here in the background thank you so much harris we appreciate you letting us listen to your music and share it here in the background while we write some code and learn together this first song is called hazel's comet and i'll let this ride in the background how's that too loud too quiet i think we're good right about there adrian is how you pronounce that fantastic i will remember that going forward adrian appreciate it we have a github repository that we use here on the channel for this show so that you can get in and you can participate ask questions um we're building out an faq out there in the wiki and we've also got all of the source code from all of the samples from every show out there i'm going to share this link into [Music] it is too quiet all right i will push that up just a smidge let me know yep the idea there we go so um i just shared the link to the github repository there in in chat if you're if you're watching the the recording like i said click the description just below there's a link in there out to the github repository let me head over there and we'll take a look here we go so here is um our github repository so that we can we can learn about c sharp together with me so it's in the c sharp fritz organization it's inside my repository right now and it's called c sharp with c sharp fritz check out the links and of course if you scroll down here we've added some additional entries if you want to run the notebooks locally if you want to know a little bit more about our community and how we're going to manage our community there is a contributor covenant and a code of conduct that we use for this repository so we can make sure that everybody's friendly and interacting with each other politely and of course all content for this video series is made available to you free of charge um open source using the mit license oh yeah it's supposed to sound a little bit like 80s power music so moving on let's talk about session number four let's talk about conditionals let's talk about looping statements so when you're writing code right and you want to do your interactions where you're going to be um you're you need to make a decision right you're at some point you're going to want to make a decision in your code do i go left do i go right which way how do i evaluate what what are the steps the next steps that we take those are the things that that we're going to be covering to start here and then we'll get into some looping statements fund my att is asking a question here and chat about how jupyter notebooks support third-party libraries there is a plug-in model there that's available that um that we're using and you can with net interactive you can request and you can have it um there's even a link here in the repository you can have it use nuget nuget packages if you would like there's a complete set of instructions over here with net interactive the technology that our notebooks run on top of [Music] so uh here's a couple more comments here good morning to samj0411 from uh let me make sure let me try and pronounce that tama lupus max mexico welcome in hello hello so let me head over i have the jupiter notebooks running locally on my machine inside of jupiter lab there's jupiter lab you see i was working on more of these while i was getting ready here and i'm i'm gonna have it rerun all the samples re-run everything yeah i know [Music] and let's let's start talking about the different statements the different things that we're going to cover today why do you keep jumping down there i'm i'm up here all right so we want to make decisions we want to make loops we want to repeat um some code that we may have written so we're we're going to be talking about these five statements that you see in a number of other languages right for while do if switch or else right how how do we use these statements to control our code to repeat code and and get that interaction that we want um so that we're appropriately evaluating code we're appropriately making decisions to code to run code not to run code to rerun and i want to start with conditionals right what are those conditions what are those test scenarios that we want to evaluate and decide go do this thing or evaluate and go do that thing now there's samples that you can execute here in the notebooks you're welcome to click through from the github repository there is a binder website here that you can click to get started and i've got it all queued up so it should load and run very very quickly here because of our new notebook images that we have available this should run much quicker and of course you're gonna make me look like a liar here binder thanks so give that a shot and you'll be able to follow along let's start with the if statement yes you're right stelzie conditional branching is a vital part of being touring complete so fischerin i'm gonna pin your question there and we'll come back to that later um if statements plain and simple you're going to structure an if statement with some sort of a test clause inside of parentheses in this case we're going to take the number of seconds that are currently on the clock and run the modulus operator against it right modulus says tell me the remainder when i divide by this number so take the number of seconds divide by two and tell me what the remainder is if the remainder is zero well then it's even and let's output appropriately a message that says seconds are even so i can run ctrl enter here and you see it says seconds are even because the current seconds on the clock are 24. and i can run this several times by hitting control enter right you can see my hotkeys down the side there and right it comes back and it it tells me appropriately when it's even or not actually it just tells me when it's even it doesn't tell me the other side of that right it just tells me if it's even and and notice the commands we want to execute when this inside the parentheses the parentheses are required the code that we want to execute when that evaluates to true are enclosed in curly braces right we want to make sure that it knows exactly the code to execute and there it is inside the braces now you can actually just put it on a one-line statement right so you you can put it together like this you can even wrap it like that but there's a danger to this and this is something that that as a coding practice you need to decide what makes the most the most sense for you in in your code that you might be writing and you might structure so if i write a one-line statement here that reads very easy right this is very easy for me to read for my human eyes but for my human eyes putting these next to each other looks like they're related but the computer when it evaluates it when the compiler evaluates it sees the second statement down here this will always execute it sees that as outside the if you may have tabbed it over you may have made it look like it's part of that if but it only executes the following statement up to the semicolon after that right it it looks it looks funny it looks confusing okay so these things wrapping like that in my practice in the way that i write code i don't like to use that i prefer to use curly braces like this when i'm going to even if i'm going to have one statement as the result of my if that's going to be executed i'm going to make sure that that it's crystal clear to the humans that come after me that need to read my code exactly what code is going to be executed [Music] i see a number of other questions here coming in let me pause for a second and i'm going to reflect over these looks like some of these aren't aren't related exactly to the work that we're doing right now um is this is that panukos asks um why am i not seeing my feature chat for visual studio go ahead try and reload that [Music] let's try it one more time there it is is this the visual studio notebooks feature so you can use visual studio code notebooks to open jupyter notebooks this is not explicitly that feature this is that this is a jupiter notebooks thing so that you can run it in your browser you can also run it with visual studio code if you would like okay ordinary boy 98 um we're not gonna cover that today that'll be in another episode that we'll cover generics that is not in in our discussion for today probably in the next looking at the schedule going forward i'm thinking we're going to talk about generics way out here probably about a month out we'll talk about generics in another in another session way out there okay um fisherin asks after learning the basics how do we learn to implement real life applications dot net gives you lots of abstractions to handle and i get lost so at this point is where it once you under right we're covering just the basics of the c-sharp programming language at this point once you know the language that's when you're going to want to take a look at doing a workshop for how to use the various user interface frameworks and i have a number of workshops on my youtube channel c youtube.com fritz i occasionally host those workshops live on my twitch channel twitch.tv slash c sharp fritz and you can see them there there's lots of other youtube videos out there where people assume you know the c sharp programming language and they will walk you through building a real world windows desktop app uh web application these types of things this is next step and this is what i see as the content for season two of this show where once we get on the other side of the basics of the programming language we'll decide a user interface framework to discuss and i have a an issue open over here where i'm asking for folks to put them out here give us a thumbs up on the various user interface frameworks that you would like to see as a follow-up here so this is intended to be basics about getting started with the language those next steps will be season two season three and we'll come back around season four might be a refresher getting back into the basics of the language um good morning eggsy if you want to learn about software architecture that's a that's another much much deeper discussion that we're not going to cover here on this channel in this series with this season software architecture is a little bit further down [Music] a little bit further advanced for for this topic but i definitely appreciate the interest in that in the discussion all right [Music] so i i hope what you see with this sample right and and please you you can tinker with this you can move things around try changing up the text right separating this out makes it look a little bit better that this is going to be executed separately it helps showing that if i really have something simple that i can do on one line i will in my code style i will put the if in that one statement on one line if it's really something simple otherwise i do prefer using curly braces in fact i even like to put a little bit of space in between these so that it's really obvious and i have some room i call it room to breathe around my statements like i do up here in this section right when you have a little bit of room to breathe around there now it's it's a little bit easier to see what's going on and i can i can add comments around those statements without having to create a whole bunch of extra space right it it looks like it looks like you're cramped for space when you when you put comments in here do this thing when my uh when seconds are even right that's like jammed and my eyes my human eyes that need to read this right it's it's jumbled together and it gets a little bit trickier to read versus giving it a little bit of breathing room there and it's a little bit clearer for me to read and this is right we have this option because spacing in c sharp is ignored right you can put as much space as you'd like between statements between parts of statements i can put all kinds of space around my parentheses here and it still works so these are things around code styles that you're going to see you're going to experience as you write code with c-sharp that'll that'll help guide and and help make it easier for you to write accurate code that does what you want it to um let's see what i see a couple questions coming in here okay now i think we're good i think we're good to keep going here so i i like giving that spa that space to breathe in those statements and down here right when you wrap like this is a pr is a preference that i don't like but you can do okay now that's great we've done if the if test if this is true do this other thing well of course there's else and else if additional testing that you can do against further conditions to evaluate and and do other things create very complex branching inside of your code so we can do something like this so now let's grab the number of seconds and if the number of seconds divided by 2 has no remainder well then it's even else if the number of seconds divided by three with no remainder if that's true well then the seconds are a multiple of three otherwise seconds are neither even nor a multiple of three so you can use the else if statement here to chain on to the end of that first if here's another test scenario that i want you to evaluate and you can continue adding those if you're going to add a catch all else statement at the end it i'm sorry if you're going to add another catch all else statement it must be the last branch here so when i execute this current seconds are 41 and the seconds are neither even nor a multiple of 3. now like i said you can't right if i want to move this right if i move this up here oh that doesn't work right i'm going to get some errors you can't start this and then do an elsif afterwards it has to be if else if and you can have multiple elsifs so if else if else if else it else if and in then with an else right so if i back that up right i can i can add another one in here and make this percent five seconds are a multiple of five right and right it'll eventually i missed it on 25 will i get it on 35 there we go seconds are a multiple of five and you see that i have these right i can add as many branches as i'd like i can delete branches right and make it just a simple uh let's put comments there so i don't delete anything right i can comment that out and now seconds are even and i well it would i would want to change that statement to seconds are odd right because it's an odd number so a lot of flexibility with how you structure these and you see that that's common in other programming languages and very easy to perceive and once again for our human eyes easy to go through because these are single lines i believe i believe we can make these write single line statements i believe you can do this let's see right so i do it like that i'm missing a parenthesis display else if display oh i got rid of the yeah i got rid of the seconds this one right here right and i don't need that one there we go so right you can do this and there are folks that when you if you are going to take this single line approach they would say we'll get these lining up once again space is optional in how it's evaluated and now it's really clear exactly what's happening there i see a couple more questions here in the chat room let me take a look over here at these um a couple of good questions let me start with this one from ordinary boy 98 um can you get some extension for c-sharp style editing in visual studio yes so very common in in a number of uh text editors code editors is the ability to use the editor config file right you can have an editor config file that contains definitions for well i'd i'd like to use tabs versus spaces and here's how wide i'd like my tab or my space indent to be there's also entries that can be added to that editor config for how you'd like your c sharp code to be formatted um if you're using visual studio 2019 it will automatically if you'd like it will automatically generate an editor config file for you based on the style of code that you already have been writing and that editor config will apply to all of the code in that folder that it lives in and any child folders so that's something that you can use to do this um i think there's more about uh editor config and c-sharp um i think there's more about it let's see here we go net coding convention settings yeah language conv conventions so you see these startwith.net right.net style this and different things that you can configure for this um let me add this link into chat and i'll make sure i add that link to the um to the youtube description it should be linked just below with the answer to ordinary boy 98's question thank you so much for the question appreciate it um as a follow-up there's a another question here so where i've done these if else ifs and i have one line i'm just displaying the result of something here um is that is that is that you can javier is that how you pronounce that when in a method is it better to use if else or if return sentences um i think what you're describing is what we're going to get into next but sometimes you'll see inside of a method return a value from immediately with inside of an if statement right um if this was inside of a class so uh let me copy that and just paste another one here and if this was a class um my time display i don't know right so here's a class and we're going to define a method here um public void display seconds right or no um string let's call this uh seconds message then calculate message sure so um let me indent these things is it going to indent everything did good so the question that you're asking and it's a good one is so here's my method and um var um display equals new right i called it my time display sure so if i said display dot calculate message right and execute that well nothing returns a value here um change that to void for right now so it's returning right it's doing the display here if i had some sort of an out value right instead of saying display this if i said uh out value well no do the display on that one right it's kind of a logger there but if i set out value equals that right then i can do this just to update [Music] right and get rid of these ones [Music] right down here at the end i'm going to return that value um i forgot to change that back to string so now it says current seconds 45 and it didn't it should have returned some oh there it is so right i have it displaying so the question being asked is well why go through the rest of this just right don't set that value just say return ah come on i'm there we go right don't set that value just return it directly instead of continuing through this is when you when you start returning values from inside of an if statement like this now you're you're going to be running into [Music] in an interesting and sometimes challenging interaction where you now have four additional exit points from this method right we learned about methods um over the last two episodes but right i've got four different places that i could exit this method and for me when i'm going through and debugging i'm not entirely sure which code is entirely executed because now i need to explore all of these different exit points so that can be a challenge nothing says you can't do this but for coding standards the way that you write code this might be a little tricky to manage it might make sense to do that short circuit exit now it might not it's going to be up to you to decide how you want to do that interaction because since i'm doing all of these return statements up here i actually don't even need that return statement or these right now it can i can actually short circuit and make it look like that um i forgot i chopped off one last curly brace there and now i have three exit points and the fourth down there at the bottom because it didn't match any of the top well here's the other processing that i'm doing sure you can do that right it's all a question of your style that you write code what makes sense for your engineering efforts um because when you make a change like this when you have it in this syntax not only are you have you created these four exit points but when i want to extend this method when i want to add new features to it if i want to do additional processing well right if i'm going to do additional processing before i return the value now i need to do that additional processing inside of each one of these right so there's questions that you need to cross you need to figure out as you decide how you want to structure your methods how you want to do the interactions so you never thought about one ifs you always drop them below yes right um some more questions coming in um and um sorry this is not a python stream today um you can there's a number of other folks that will be talking about python later today not on this channel but elsewhere but uh sorry about that that's not something that we're going to be that we're going to be talking about on this channel um a trivezano a trivezano asks about what about switch statements spoiler alert coming up next stay tuned but uh similarly viralflows asks does elf does if else and switch have the same performance is it safe to use switch case performance performance if you were to use the same similar syntax using the same branching is going to be negligible um is it safe to use switch case yes it's always safe to use switch case and we'll see that in the next segment but performance is negligible between the two should be the same so now no problem at trivezano i appreciate the looking ahead and suggesting oh because what you've done is you've validated for me i put these in the right order i have the correct i have the correct content here in the right order for us so thank you i appreciate that um and if you are using the the jupiter notebook on binder you're welcome of course to scroll down and check out what's next and you'll see we're gonna write the loop section live on the broadcast um okay moving on so that that was a good question about the exit points very good question and and i almost feel like we want a session dedicated to class design and method design right once we know how to use the programming language i think there's there's maybe a series we want to do of two or three shows two or three shows about class design class design practices that we should probably dive into um and that would be a little bit further out um uh what makes good class design solid uh principles yeah let's mark that as a future show idea because we are getting a number of class design types of questions and that's absolutely something we should look at in the future and figure out how we want to bring these together um i'm going to pin that question in travisano as we get into switch statements you're right stelzie that is a very good point here um many loops and if or switch statements are rewritten and optimized by the compiler don't optimize prematurely optimize first for your human eyes because there's other developers that are going to read your code at some point it it it might be you a year five years in the future and you're gonna need to rewrite your code and you're going to hate yourself because of the code you you wrote it doesn't matter what code you wrote it could be the most beautiful code ever developed ever written you won't like it it doesn't matter it happens to everybody they look at the code that they wrote at some point in the past they'll go man i should have written that better this way because you learn you evolve as as a developer and and you make different decisions compared to what you used to see and other teammates other folks that that maybe work on your open source project the project at your employer and they'll look at your code and they'll say why'd you make that decision don't optimize prematurely optimize for the human eyes that need to read your code first um i like phone my att is called saying when you if you have too many of these you end up in if else hell yeah yeah right too many of these statements that those branches that you now need to test and figure out and and have your human mind debug right because the debugger might come back and tell you something you weren't expecting right maybe maybe this is a one and it's not behaving appropriately wait no seconds aren't a multiple of three well now i need to go back through and debug it and now i'm looking through and it can get a little confusing so these are some good tips some good feedback from the chat room about how to how to more more cleanly structure your code around some of this um uh is that panukos says true looking back on on their first app project from three years ago and yeah it doesn't matter what you wrote you're not gonna like it it doesn't matter you're gonna be like wow why did i do that because you did and that that was what made sense for you at that point so um you can also chain together statements using the logical or and the logical and operators so the vertical pipe is used for an ore the uh ampersand here ampersand is used for an and operation okay so let's take our little seconds example here and let's push this out a little bit further let's test for both a multiple of two and a multiple of three so if seconds divided by two have zero remainder and seconds divided by three has zero remainder then seconds are even and a multiple of three else if seconds divided by two has no remainder it's even else if seconds divided by three no remainder is 0 seconds are a multiple of 3. we can add other statements onto there if it's a multiple of 5 or a multiple of 7 by using our or vertical pipe operator to separate and execute that and you'll see it's even it it did not pass both halves of this right true and false is false so this is true so it evaluates and outputs that and i can continue testing here and we can go through and see exactly how it would evaluate and of course right maybe you don't want to keep pressing return here right just hard code with the number of seconds are right just hard coded so this way i'm trying to get it to randomly choose something in here but you're welcome it's your notebook when you go through and try this on your own tinker with it and try some of these different statements but i think what you are seeing here is right we can start to get very complex in our interactions with these now something that you'll see a lot of c-sharp developers do is they'll start to use the short circuit operators where you put two ampersands where you put two vertical pipes this crea is the conditional logical and you'll hear folks refer to this as the and also operator right visual basic connect it's actually called and also so what this does is it short circuits evaluate the left side when you use the two the two uh ampersands next to each other evaluate the left side if that's false don't even evaluate the second the second half what's on the right side of the operator stop processing return false right now if it's true evaluate the right side and return the result of the right side [Music] so let's look at this so now i'm gonna write a method called multiple of three [Music] this time we're going to return a boolean to indicate seconds divided by three is zero has a remainder of zero right it's a multiple of three and i put inside of here a little display statement that says multiple of three was called this way we can see when we evaluate this there we go current seconds 26 that's an even number so it's going to go and evaluate multiple of three and decide is it a multiple of three it evaluated that and came back false so it didn't output any additional information so here 47 47 is an odd number so it didn't execute multiple of three this is false stop processing immediately right and we could continue there's there we go current seconds is zero multiple of three was called seconds are even and a multiple of three yeah three times zero is zero so if phone my att you're right it's best to return early right i've stopped i'm not even evaluating the second sun i'm not even evaluating that additional code i've short circuited i know immediately this is going to be false so there's no no reason to continue processing right you saved a couple processor cycles by not going into that other method it's an optimization that you can do and a lot of folks when when they don't care if the second side is evaluated we'll use the double operator here and the same works with the or the conditional logical or double vertical pipe sometimes referred to as or else okay so um evaluate the left side if it's true return true stop processing we don't need to figure out if the other side is true return true stop processing immediately otherwise return the result of the evaluating the right side of the operator so here's a couple examples of how you can use that i did the same thing here with multiple of three so seconds percent two if it's even or it's a multiple of three seconds are even or a multiple of three and it's not even right if if it is even it's not even gonna calculate multiple three it's just going to return well it's even or a multiple of three but if it's odd right let's get to odd there we go it tested for multiple of three and then returned seconds are even so we're only executing that second side if the if the left side is false so this way right we we short circuit we only execute when we need to i see a couple comments here let me take a look at what's what's over here there are there are one or two other logical operators that that are out there um exclusive or is out there that you can use it's a little bit further along for some folks but i have a link to the conditional operators here in the documentation you can go check that out if you need to learn a little bit more about how to use that um uh that's right viral flows a single pipeline is enough for a for an ore condition but it will evaluate both sides of the ore so it will always do that so if i change this to a single pipe it's always executing the right side right um so multiple of three is always called even though it's an even number we're saying even or a multiple of three it still executes the right side so this is where if you want to short circuit you can by using that double pipe and if i let's once again force this right if i force this to six it doesn't execute multiple three but it does every time when i have just one pipe there okay so it's it's up to you does it make sense in your code to always execute the right side in your statements i don't know but you have that option that choice available to you that's right toucharm um there's instructions on how to do that in our github repository to run c-sharp with jupiter and you can get all you can click through and run our jupiter notebooks with the binder link inside there there's a couple other questions here in the chat room let me um let me answer these i still have a trivezano's comment there the question pinned there um about switch statements but i will come back to that um this behavior is very good for null checks stelzi that's very good um i'm going to just pin a couple of these questions here and we'll go through them um yeah i'll put some of these comments on the screen also um very good points here mara corvus i love that comment keep mental juggling to a minimum mara's spot on here keep your mental juggling to a minimum for anybody that's reading your methods absolutely right writing writing code writing with a programming language can be a complex interaction there's a lot that you have to keep in your mind and you're figuring out as you're writing as your writing code and quite frankly the person coming after you that needs to read your code might not be as clever as you they might not be as smart as you they might be smarter try and make your code as easy to read as possible make it as as simple and straightforward for the next human to be able to interact with i that's a fantastic point there mara thank you so much for sharing that um the music we're playing today this is uh stream beats by harris heller and we're listening to the synth wave playlist [Music] um there's some questions about raspberry pi's um right including this one for from is this georgie porgy will be the best beginner language to code with raspberry pi's for some electronics and robots so this is a very loaded question because you can use any programming language to work with raspberry pi electronics and robots there are folks that will tell you javascript is the only programming language that you should be using with raspberry pi others will say python um i believe c sharp because c sharp is a very flexible and robust language that works everywhere and does everything where you can't do that with those other programming language languages so as a beginner language that you can go forward and do anything with that's why i like c sharp because i can build i can build desktop applications i can write little code samples like this in a jupyter notebook i can build things for a raspberry pi i can write interactions that run in a cloud with serverless computing i can build mobile applications i can build web applications the world's your oyster if you choose c sharp and you want to use that there's native frameworks that you can use for all of those things using c-sharp not so much with python and javascript there are tools out there to do a number of those things but there aren't as robust frameworks for some of those interactions so it's a very depends type of question so but that's why i like c sharp for it and that's why i wanted to teach this series here on um on stream [Music] so folks that choose python choose javascript there is no compiling it's strictly interpreted that could be a good thing that could be a bad thing right this code is being compiled there is a compiler that's verifying it before i have the opportunity to run it and that's one of the interactions that you get by choosing a statically typed object-oriented language that has a very strong compiler that runs with it also means you get a very robust set of tools that you can use as well um comment here from left-handed shmo the end also conditional and operator let me scroll up to that up here um is really helpful if the statement on the right relies on particular results or values for the left side and either doesn't apply or will fail if the condition on the left isn't what you're looking for yes yes right so if we did something here right if seconds um does not equal null and seconds uh where is it percent two equals one right display uh seconds are odd right i i can do that there and right i need to make sure seconds are not null before you go and start interacting with it now the seconds this is a value type it's never going to be null but right if you're doing that type of a check that i need to i need to make sure that this thing is true first before i even attempt executing the second half of this yes your your spot on their left-handed schmo i i can't believe i'm addressing left-handed left-handed shimo is right this this provides almost a guard statement on ensuring that you don't even try to execute the right-hand side when it might create an error scenario very cool mara spoilers ternaries are coming up next um all right let me continue here a new feature that was added recently to the c-sharp specification is called pattern matching now pattern matching is a way for you to test that something matches a shape right matches the the this the shape and style of something and you use this is operator in in your testing process you can optionally then assign that to a variable so i can do pattern matching with my if statements here so let's define an orange and an apple oranges and apples aren't the same right oranges i'm gonna make juice i'm making orange juice when i execute the make juice method apples i want to make i want to make an apple pie so i'll have a make pie method that displays making apple pie and let's define just an object of type fruit right i can even make this a var here right and execute this uh no i can't i can't i need to make that generically an and i could say well i'm going to define a fruit that is a new apple well if fruit is an apple make pie [Music] else if fruit is an orange make juice otherwise i don't know what to do with this fruit so right if this is null i don't know what to do with this fruit right i'm doing this is test to to match the pattern of what what is that thing that we're working with and we're is testing and that's very simple pattern matching there's a lot more that you can do with pattern matching that gets into some other features of the c-sharp programming language that we haven't covered yet and i will have a further pattern matching uh session at some point in the future as we cross things like collections um and some of the other things around in object inheritance and and uh object hierarchy in the future but i wanted to briefly show that you can do pattern matching like this with if statements all right i like the the joke there from stelzie sure we'll put that up on let's put that up on screen clearly apples are cell phones and orange is a cell phone provider uh-huh he's true he's right yeah that's a thing so so these are the these are ways that you can interact in further tests inside your if statements [Music] so continuing this is where this is where mara was was interested in going and she's she's spot on here next is well what if we want to have expressions that we conditionally execute we conditionally assign or set the result of that expression using the same if then or if then else syntax and that's where the ternary conditional operator question mark colon comes into play [Music] so it's this is used in this syntax you have some condition on the left side of the question mark test this thing is this thing true if it is true yes is the result of the expression if it's false no is the result of the expression so we can use this now to assign to a variable we can use this in an if statement which is weird and we can chain these together so let's take a look i'm gonna use that same seconds example right let's get the the current second test if the seconds are a multiple of two let me put a space in there so now var result result equals seconds percent two equals zero right there's that same test that we were doing up here inside of our if right if seconds percent two but we've now turned it into an expression that we're assigning to a variable here right let's put a little bit of space in here so if that's true and i even added a little comment here even is what we'll set to result if false we'll put the value odd right and even odd right i can keep executing this with ctrl enter and you see it it pivots back and forth right let's uh display uh the current seconds are and we'll just add seconds right 54 that's even right and you see how it very cleanly does this ternary conditional operator right and that's kind of clear when you have just one statement there and because each one of these are themselves expressions we can start to chain these together so now let me do the same display here let me bring that in right now it gets a little bit a little bit nutty because i can say results percent two equals zero well if that's true then seconds percent three equals zero if that's true also even in a multiple of three if it's if this is not true well then it's even and not a multiple of three otherwise this one see now now i've got multiple question marks and multiple commas and it gets a little weird gets a little bit tricky you can use parentheses to add some grouping to set some priority for how these operations are being executed and um actually i would i want to put it there and it also makes it clearer once again for my eyes my human eyes to evaluate this those parentheses don't do anything for the compiler the compiler doesn't care it sees that as a priority that that it's going to execute as one unit but it was already doing that anyway so you haven't changed processing here all that i've done by adding those parentheses is make it easier for me to read this right so be careful when you start to chain these together like i said it can become unreadable but on the other hand of that there are some folks that think they're brilliant because they'll put they'll put a full line 80 characters long full of question mark calling question mark calling question mark colon colon calling question mark i don't want to read that that is so confusing for me but for them it makes perfect sense it's all about supporting that next developer after you remember that yeah uh nested ternaries are a little bit they're they're extremely powerful but it can get just a little bit confusing like i said for the next person so maybe you wanna maybe you wanna break this up right maybe um right maybe i wanna make this multiple of uh three right and here let's let's do this on another line right maybe i do this and i can take that and put it here and i can now do right because it's an expression and display takes an expression here right i could do something like this and put a multiple of three [Music] right now it is executing this statement every time but i have made it a little bit clearer i've also allocated additional memory i've allocated another variable here okay not terrible but for my human eyes again easier to read and that's that i hope that's a little bit of a theme that you're picking up here is you can write your code and structure it however you'd like right but make sure that other folks can read it you can even right if you want to make this a little bit easier to read we can put some carriage returns in here so that it's clear right a little bit of the the break up and you can nest that and it still works because it's going to execute all through this as one statement until it sees a semicolon so right go ahead and tinker with that you have the you have the notebook go ahead and play with it and see what makes sense for you [Music] you might as well be using excel ifs says coldfire you're right yeah right it does start to look like an excel if statement uh if formula in excel if you're familiar with using excel formulas um it is by no means pretty you're right tinker with this then never do it again no no no figure out what makes sense for you and for the folks that you're going to be working with now the next operator i want to talk about kind of fits in here is the null coalescing operator the double question mark so what this does is inspects the value to the left of the double question mark if that value is null return the value to the right and you can combine this even with an equal sign to evaluate and assign that value if it is null right to almost default something so you may write this type of syntax if we were to use the ternary conditional up top here test if test does not equal null will return test otherwise and do something else and set that value you you can write this this is perfectly valid but the double question mark makes it a little bit shorter and a little bit a little bit more concise that's the same thing i'm saying twice there makes a little bit more concise in how you're structuring your code so if my value is the string test i can say display my value double question mark it's null well my value is test so it displays test if i change this to null it returns its null it is purely syntactic sugar right this is something strictly for humans to be able to interact with and write shorter code it does the exact same thing there's no performance hit on using this versus that but it makes it a little bit easier to read and you may find ways to interact and write this and build some cleaner code on this so okay now the next one the next one of these question mark operators that i want to show you is the null conditional operator this is an interesting one that that i think is kind of fun so it tests if the object to the left of the question mark is null and conditionally continues execution and it yes it was sometimes called it was originally colloquially called the the elvis operator because of the right you've got two eyes and a little bit of curly hair above it so let's set up a student object in public string name so if we create a new student and we'll name that student fritz display our student's name is now by using s question mark dot name it checks to see is the student null if not continue processing so if i change this like that now i get our students name is nothing nothing there here's where we can chain this together with the local lesson so now i can do something like well if i didn't get a name right i can say student uh or right the student doesn't exist student is not assigned yet um and i can forget to put another parenthesis there and end it one more parenthesis there we go our student's name is student not assigned yet right and we're juggling and we're dealing with that null appropriately right if i take this back let's let's actually copy this so that you have it available right so now our student's name is fritz the student does exist so it just returns the left side you got it lithics the double question mark is the end then right the up here is this null yes and then do this is this object null no return the name if this is null the whole expression is null and then return this let me add that as a comment block here right let's go over here right if uh s is null return null right and i should actually let's put that as another line here inside this block and this one i won't include the conditional right if s is null return null um else evaluates the name property right and it doesn't matter what the name property is here right name equals foe still works [Music] right here it's if uh s is null um if s let's say if s is not null evaluate the name property right else return the string uh student is not assigned yet right so i hope you see the difference between the two right um i can do this [Music] right so comment that try this there it goes and you see the difference between the two statements so once again tinker there's other things you could do there with the ternary statements to make that work appropriately for you [Music] there is so for those of you just coming in there is a github repository for our session today there it is if you click the binder the the launch binder button right here in the readme it'll launch the jupiter notebook that we're working on today and you can get right in to where we are here inside of um inside of our code inside of our documentation that we're working together [Music] uh is that gabangang asks do i manually type let me put that up let me put that up do you manually type the double forward slash or am i using control forward slash i'm typing double forward slash is that a shortcut ctrl forward slash is that a short shortcut here to comment in jupyter notebooks no no um inside some of the editors some of the code editors you'll see there's shortcut keys to automatically comment lines i'm just typing the double forward slash to get that to work thank you for the question much appreciate um just taking a look around here good good good good so the next piece that we want to talk about here and i'm going to come back to a trivia trivizano's question from earlier about switch statements but we're going to talk about switch statements this is the next conditional thing that you could do now switch statements allow you to evaluate a single statement and determine a branch to traverse in your code you're evaluating one statement and based on the result of that statement you right you have an expression whatever that evaluates to go do something else about it so instead instead of saying if else if else if else if else if you can do switch case and go through some expressions at that point now control k control c don't think it works no it doesn't because control k pops me into my into my search box so let's do this let's take a look at days of the week okay so if we have the days of the week datetime.now and if we switch right here we're going to switch on the expression day of the week what day of the week is it well if it's monday we're going to display this message tuesday wednesday blah blah blah blah blah it's going to display all of these messages and if it doesn't know what day of the week it is we have a default block down here so we test that the result of this expression is a specific value now it has to be something that is evaluated by the compiler and known at compile time in order for you to do this case statement so case whatever that value is followed by a colon it must be in that syntax then whatever statements you have after that you can have multiple statements here all of those will be executed and will stop at the break so if i execute this code does somebody have a case of the mondays because of course today is monday when we're broadcasting you're welcome to change this if you want to tinker and see what happens when you choose a different day now that's that's kind of cool but we can also um yeah let me do the fall through so we can also fall through from one statement to the next so if i want to have saturday and sunday kind of grouped together here right i can bring these down here if i eliminate the break between them it will fall through from one statement to the next so if i change this to saturday now it goes and executes and the checks the day of the week it matches this case statement falls through because there's no break until down here and executes that display i'll get the same result if i choose sunday as well so you can kind of pivot your various case statements here and have them work together if there are multiple scenarios that you wanted to do one thing getting their phone my att spoiler alert so there there are ways right there there are ways that folks will use switch statements to um simplify their if else if types of statements because this becomes very clear i'm only executing and testing on one value day of the week and here are the various branches that i'm going through you can add additional context maybe you want to do an additional test on each one of these case statements and we can introduce a when clause so check this out so we can say switch day of the week if it's monday tuesday wednesday thursday or maybe it's friday when the hour of the day is less than 16 it's less than 4 p.m work work work work work if it's friday when the hour of the day is 4 p.m or later weekend starts now go right and here we'll do that same fall through where it's going to pop through so work work work because it's monday and it's 10 30 a.m here right but we can also right we can also tinker with changing it to friday and 5 p.m and now you don't like it no there we go the weekend starts now because day of week is friday it it matches this part but it fails the when clause right matches this part and does pass the when clause so it decides to execute this so you have options for how you can extend this in the future if you have additional case statements that you want to drop in and insert them here these are evaluated top to bottom so right and it should match one and only one of these statements okay so for monday hour 17 it doesn't return anything that's right if i force this to well if it for monday hour 17 it's going to fall through and execute here work work work because it matches this case statement and falls through right because it doesn't have any break statement it continues executing until it hits a break statement and it i so there's another thing i didn't add a default statement you can use default statements like i did over here as a catch-all didn't match any of the cases so it's this thing instead right so different options that you can use to control flow inside of this now i'm going to come back to trevizano's comment here professional rule of thumb if you need more than three if statements use a switch that's not a bad point that's not bad that for a code style i can get behind this there are cases where it might make sense that you need more complexity in your if but more than three if else if else if else if yeah start looking at using a switch case statement because it'll make it very clear how you're executing how you're interacting and how you're returning data so very cool interaction now you can use these also with pattern matching i'm not going to get into the specifics of that with switch because there are some more complex things that you get into that we'll cover at a later time but you can do this you're welcome to do the research and see the the the syntax is linked up here if you'd like to click through and read the official documentation about how you can do that a feature that was added in c sharp eight is called switch expressions and this doesn't work in jupiter notebooks i tried my darndest to get this to work and it doesn't work so i'm i'm going to with respect pass on showing this running here but this is the syntax that you would use instead of having a switch statement that returns and and maybe sets a value to um to a variable in a switch statement you can instead say well var this variable equals take this expression and switch on it when it matches this value here's my expression that i'm going to execute you get much tighter code here it will it looks right very clean and here's how i'm writing these things it it feels very functional in structure but there are some object-oriented die-hard people myself i'll include in among them that look at this and this is syntactic sugar for folks right you don't have to use this you can still execute with a switch statement but looking at this it's a little bit confusing for folks because they're missing default and break statements that you would use here this is only available as of c sharp eight works in net core three point three point something in later so three point zero three point one dot net five and later and net standard i believe it's 2.1 in later i think is is what that should be if i look at this i believe it's c sharp eight um i believe it's dot net standard 2.1 and later i will confirm that [Music] um need to confirm i will confirm that and update the notebook appropriately with that documentation yes you can have a default you can have a default by by using the the underscore um it's called a discard right uh default statement right you can do this it's not the word default so it looks a little confusing right we're getting a little bit more machine focused in terse very concise in the code that we're writing possible but and you don't need to write break as well it's a single expression on the right of the the um the fat arrow right where expression body member is here on the right side so you don't ever have to write break over there so doable but it can be confusing it is a c sharp 8 feature so that means it does not work in that framework okay net framework being the framework that runs on windows.net framework 4.8 you may use it with asp.net web forms you may use it with wcf with windows forms wpf applications uwp this does not is not available for those user interface frameworks so wpf and windows forms if you recompile them with net core you can do this but now i wasn't sure if we'd get into it but we're here we made it let's talk about looping now c-sharp is not moving towards functional programming but it's taking functional programming capabilities [Music] so there's a question about omitting the word break you can't use the word break here the word break for these switch expressions is not used because it's just a statement over here that ends with a comma and these are the various expressions that it's going to evaluate so you're never using the word break in this syntax when you write with a switch expression a switch statement you must use the term break if you don't include the term break here it errors out okay and it's always the the last break you need right i can certainly put a break here now why oh because it already started some execution in here once you start execution you need a break if you stack the cases like this you don't need a break statement yeah the default section at the end you do need a break statement so how would you write multi-line let me put that question up from viralflows how would you write multi-line code in switch expressions so use um some curly braces here just like you would in any when you use these immediate interactions right right display this is monday [Music] right and then you're returning i believe that's the way you can do that i look at that and i i say you know what you've you've kind of lost a little bit of the value of the switch expression here and i would move that into a method instead so that you end up with these very clear just assigning values coming out of it i believe that's the way to do it is with is by adding curly braces i will i will verify that and uh [Music] and update the notebook appropriately uh how to format multi-line expressions um expression bodied members i will get that updated and in there for you all right [Music] let's talk about loops so we've got about 20 minutes left 25 minutes left loops are um right this is one of the basic things that you're going to do in every programming language you're going to write some sort of a looping structure so right for loops [Music] are typically in the syntax of [Music] right a normal for loop right you're gonna initialize some counter you'll see all old school folks like me call that counter i but it can be any variable name and i is less than some um end variable right finally you have the step for well how does that actually increment not i i plus it should be i plus plus right we learned plus plus increments and sets the increments by one sets the value back into that variable so it starts off initializing the loop with i equals zero tests well is i less than the end variable if it is then execute what's inside the loop when it's done executing what's inside the curly braces increment the value by one and proceed through is i still less than that invariable yes continue executing the loop so you would see right let's write a simple for loop um var uh let's put end at equals five and i don't even have to use an end variable like that right i could say 4 var i equals 0 i less than 5 i plus plus and i can say display uh counting right and if i execute that code it displays counting five times i can use my variable inside of here and it outputs the value of that variable okay that's not bad um right i mean easy ways for me to interact with this now you can make this whatever you want the the variable can be whatever variable name you want right um let's not do that yet there it is so it still works if i change it but if i try to use that outside here it doesn't exist the counting variable is only available inside the curly braces so you can no longer interact with it right when you get out you get outside additionally you can change what your step is right maybe instead of incrementing by one i want to count by twos right uh get rid of get rid of that right now i'm incrementing by twos zero two four it would increment to six well that's greater than five so stop processing right i can make that three and zero and three next one will be six stop processing so right easy to interact and structure a for loop that that does these types of counting i can also count going down right and it will count going down start at five while fi while the counter is greater than zero subtract three and it counts down this can be any arithmetic operation you would like over here you can even call another method there if you'd like right um but and these can be expressions as well that you may want to have execute and it will step appropriately so let me do this let me copy that for loop and let's undo um i'll add it back in there so you can see uh oh nuts there we go um loops can even count backwards there we go so it's kind of broken up okay so how do we do an infinite for loop is what phonemi my att is asking how do we do an infinite for loop well maybe right and and right this is gosh you don't you don't want to do an infinite for loop let me make sure i save this first right uh what about infinite four loops so right i mean if i did this right and i want to i want to run that as long as the counter write it maybe counter starts at one and continue running it while counter is greater than zero that's an infinite loop it's always going to run counter starts at one right um i'm going to continue running this while the counter is greater than zero so it's going to continue running stop jupiter stop [Music] so that's a problem don't do that [Music] okay so make sure this is an infinite loop uh be ready to kill your notebook with uh the stop button above okay uh let's go [Music] so let's restart the kernel [Music] and i broke the internet that's right no more internet there we go saving completed should restart here in just a second and we should see that display statement pop out down here there we go it's gonna go through see the little asterisk there you go executed that yeah so you can do this and that might be okay if you have some other conditional code that you want to stop and break that statement so right maybe i'm gonna write i could i could do this and i could put a thing in here right your for loops can stop if you put a break statement in there right so i can do something like say if counter greater than 10 break right and now it executes counters greater than 10 stop and it it stops there so you may want to structure that for loop right maybe maybe this is if counter percent 100 equals zero uh oops double equals for the test now it's going to go through and do that and until it gets to that scenario it will it won't stop so be aware when you you can structure these and you want to make sure that you break and stop appropriately and you can do that with the break statement [Music] um now let's do this let's do this put put a break there mark down and uh break statement in for loops i'll write a little documentation to go with that i see a couple of questions a couple of comments um [Music] so curiousdrive asks a question here what happens if you decrement the counter in the for loop as one of the statements let's try it so i'm gonna go back up here let me go to this for loop um tell you what i'm gonna split that let me grab this and uh delete that and let's turn this yeah that's already more right that's marked down there we go okay so if we're up here in this statement and we go to modify right if we say counter um minus equals one right decrement right and we try and execute that it works you can do that and bad things happen right it never reaches five right oh no so rule of thumb generally is don't tinker with the um don't tinker with the counter changing and assigning values for the counter inside of the for loop that's a problem that that's going to create a problem now phone my att asks kind of an interesting question here we did counter plus plus well what about plus plus counter so from our first episode together this should this is restarting here and it's going to re-execute you see a little star here still executing parsing reloading the net and and running here you fight [Music] you should not have come out here there we go so here in the first episode together that we had we talked about i believe plus pluses in here isn't it looking looking uh you know what i didn't do plus plus in here oh no i need to add that [Music] i need to add that [Music] uh increments and assignments operators right uh plus equals plus plus we need to cover that at some point um you know that or i'll go back and add it in so there is a difference between using counter plus plus or plus plus counter and that has to do with when you're incrementing and assigning so in doing counter plus plus i'm getting 0 1 2 3 4 because it's taking the value of counter adding one and assigning if we go the other way we put plus plus up front it adds one to the counter and assigns first now for the purposes of this it's no different right it's actually the same but it's a question of changing the order of the operation right we're evaluating the value first before we we're evaluating the value first and then incrementing it or if we put the pluses up front we're incrementing the value and then evaluating it which i was expecting it to be one two three four five and it wasn't [Music] so i'm not sure what that is yeah i was expecting one two three four there [Music] okay [Music] do the same thing on the display call and remove the remove the increment from before um well if i do it there yeah see i need to right now it's uh yeah that looks weird um because i'm concatenating on the value and it's incrementing inside of here [Music] if i turn it around and go the other way now it's zero one two three four so you see the difference i like to keep that up here it's optional but i like to keep it up top with it [Music] [Music] okay um moving on so we did break statements next thing that i want to show you is for each and then we'll get into while and do loops all right so for each and we haven't gotten into collections yet but for each is when you interact with a collection and you want to go over each item in that collection and do something with it now a collection can be an array it could be a dictionary it can be a list there's a bunch of different collection types we're going to talk about collections in another stream but we're going to at least show you how to do a for each with this okay so let's write let's set up a in i'm going to allocate an array here um and i'll start with a simple string array um so we declare string arrays by saying new string square brackets to indicate that it's an array and we put values in here so we'll put fritz scott um maria um and uh jamie okay and now i can write a for each loop that says well for each var name and use the in keyword are names and i'll be returned not a position but a name inside in order from that array so if i can say display uh name and it will iterate over and display for each name in that array here's the names when i go and add another name in here [Music] it just continues executing and i haven't i haven't changed my for loop it's still going over all the items in that collection handing off here's the object i found for you to interact with no i i spelt sure we'll put mara in here sure and there's mara right so maria is another member on my team so i used maria there you go so right for each is is very useful because you'll you'll see in a lot of net code you're working with a collection of objects collection of records from a database collection of inputs on a on a user interface and you can interact with that collection without having to go and calculate well how many items are in this collection let me get a pointer right let me go get because i can i can do the exact same thing as this for each right um right i can write a very similar for loop right four var let's call it name counter equals zero um name counter is less than uh our names.length right that's the length how many entries are in the uh in the array um name counter plus plus right and i can do instead of display name display our names name counter and i get the same thing coming back can be done right but i'm i just want to iterate i'm i'm reflecting over i'm inspecting each of the objects in the collection this four syntax is a little bit more clunky where it's a little bit more elegant to do the four each because i it declares immediately that intent of i'm looking at each of the items in this collection and working with those that's right mara you're part of the team now no i'm not going to iterate on a string ah i'm fine a string is a is a is a character array so right if we have a right if we have a variable fritz that's a character array right so i can do the same for each right bar and let's call this uh a letter right not ladder letter and now it iterates over each character in the string because the string is a character array i can do the same thing with the with the with the counters here as well and instead of being our names length it would be string length right um call this letter counter name dot length is the the length of the string and display name letter counter and i get the exact same thing okay here split that uh no mark down uh strings are character arrays that we can also iterate over okay so yes you can 4-h with reference items to modify them yes yes as long as it's a collection you can do that [Music] we're nearing the end of our time together i want to make sure i cover while and do these are very very similar right but it's a question of when you do testing so you can create a while loop here that says while some some scenario is true right so if i say var counter equals zero i could say while counter right less than five display counter um and it's going to continue doing that because i've created an infinite loop again because i didn't increment counter yes restart oops and this is going to restart can i do a for each across reference can i show a loop across some uh reference types um sure it's still uh re-executing here um there we go [Music] so if i go here right if i um i already have person allocated up here don't i uh student okay so if i say of our students equals new student right and uh i allocate some students in here name equals fritz um new student name equals uh mr anderson okay i can do a same for each across that uh var uh sure in uh students right display student dot name there you go so you can go across those reference types as well all right um this should be let me move that it should be up here okay so you can go across reference types i'm doing numeric types because they're nice and simple for us to go not going into structs structs are going to be later structs are a way different topic but we're see we're testing with the while we're testing at the beginning of this a do loop turns this around and says do this thing then then test at the end right so we've moved the control of this so that it tests after the interactions now in this case they're both the same it's doing the same thing both in both scenarios but do while and while just move the execution point in which you're executing all right in which you're you're testing i'm sorry you're you're testing to decide whether to run this again right so um i'm not sure i don't think that's going to so i get one two three four five um and if i move that up yeah i get the same thing i'm trying to think of a way to show the difference between these two i'm going to put together a demo that that i'll put in here that shows the difference in execution between these two the display function is is inherent to the jupiter notebook that's a feature that the notebook has that it's returning and showing us we'll talk about for loops aggregates and selects with link when we get to link in our collections discussion later we're not there yet not there yet i appreciate the interesting the the the interest in doing some of this um i could show this by making counter equals six uh sure let's do that let's say counter equals six here see it's um [Music] right if i and if i do counter equals six here the same thing happens in both of these right it still executes right if i make counter equals six above right if i do that here and i still make this uh counter plus plus right right this one doesn't execute at all this one does execute yeah thank you whimser for the for the uh suggestion there so it the while runs the test first then decides to execute what's in your and will continue executing do will execute this and then test and decide whether to continue running that loop good tip thank you for that um let me save this i'm going to commit these changes i'm going to push this back in and we'll update the jupyter notebook that's out here inside of our code repository let me share that github link one more time because that's the end of our two hours together friends thank you very much for tuning in let's head back over to the display so we covered we covered a lot we talked about conditionals if statements switch statements switch expressions and we saw how these all fit together how they all work together to make make all of these things that we want to decide different ways that we want to go in our code how we want them to behave we looked at for loops while loops and do loop so we can control when and how they we proceed through and interact with our code that's a very cool thing you know how do we want to iterate how do we want to repeat things how do we want our code to process it's very important that we know these things as we continue to build c sharp code thank you so much everybody for joining me this was a this was a fun session together we had a couple of really good questions that i was happy to answer and uh i look forward to seeing you next time
Info
Channel: dotNET
Views: 6,501
Rating: undefined out of 5
Keywords: .NET, C#, csharp, csharp with csharpfritz
Id: 3PSgjUX3maE
Channel Id: undefined
Length: 116min 55sec (7015 seconds)
Published: Wed Sep 02 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.