Introduction to C# for non programmers | Strange Graphs | Skillshare

Introduction to C# for non programmers

Strange Graphs

Introduction to C# for non programmers

Strange Graphs

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
13 Lessons (3h 20m)
    • 1. Introduction

      1:01
    • 2. Intro to C Sharp Installing Visual Studio

      6:11
    • 3. Creating a C Sharp Project

      5:20
    • 4. Variables

      10:54
    • 5. Calculations

      12:24
    • 6. If Statements

      14:30
    • 7. Arrays and Lists

      16:02
    • 8. Loops

      24:40
    • 9. Intro To Functions

      12:36
    • 10. Classes Part 1

      21:12
    • 11. Classes Part 2

      25:58
    • 12. Installing Sql 2019 Express Edition

      8:50
    • 13. SqlServer Basics

      40:39
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

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

9

Students

--

Projects

About This Class

You will learn some very basic principles of programming in C#. Variables, Calculations, If Statements, and Loops

Meet Your Teacher

Class Ratings

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

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

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

phone

Transcripts

1. Introduction: Hello and welcome to the course. Introduction to Logic. Using C sharp step by step, this course has suggested for absolute beginners to programming no prior programming experience is required. Why c sharp, you might ask. C Sharp, in my opinion, is hands down one of the easiest and best tools off the market for programming. C Sharp is much more simple than complex programming languages, such a C plus plus and others. So with that said, let's get started and also thank you for viewing the course. 2. Intro to C Sharp Installing Visual Studio: Hello and welcome to a class. We're going to start today by downloading and installing Visual Studio. You can see that right now we're at the Visual Studio dot Microsoft.com website. And while you'll want to do, if you're on Windows, you'll want to download community 2019 and Alessio, professional or enterprise already paid for. In which case you'll want to get either one of those. But let's, for the purposes of this demo, Let's go with community 2019. See click on Download Community, community 2019. It pops up something asking what you're doing. And then after downloads, and it'll bring up the installer, which I'll show in a moment here. So once the download is complete, you'll need to open the installer. It'll ask you if you'd like to allow the device to make changes. For the install, just click yes. And then click Continue. Before you get started, we need to set up a few things so that we can figure insulation. So they have an installer for the install. So just click continuum, that letter download, new, update, mid, sell, whatever needs there, takes just up to a couple of minutes. Sometimes lasts. And okay, so this is the installer. And it lets you choose different things that you might use. While using Visual Studio. Just see sharp. For the purposes of this video said, we'll be installing. We'll, we'll, we'll just need the stuff or C sharp, but, and probably Xamarin, but we're just going to wear, but I am going to include other things that I might need later. So ASP.net and web development, I would suggest getting that even if you're not using it yet. Development, I'll get that. I don't really need NodeJS, Python. I'll get those. Let's see. Also, Python two might be good. Over here is optional. Things that you can get with all the packages that you're installing. The click over here. So we definitely want that target desktop in development. So we can develop Windows applications like Windows forms, WPA, and console applications are gonna get c plus plus as well because I do a lot of different types of dual bid. And then yeah, this, this is for Xamarin and mobile development. So I always get that. Universal Windows platform development as well. And also get goiters, test dk, case it or have a USB device connectivity when as well. Let's see, mobile development with C Plus Plus. I never do that. So sleep alone, extension development in case I want to do that. On their core cross-platform. Let's see. Linux development with C Plus Plus. I might need that sometime. Oh yeah, data storage. You need, you yo want to get this data storage and processing. At some point we'll be putting together a segment on databases as well. So with C-Sharp, so that's more to cover in the future. Also, you may or may not want gave development with unity or game development was C plus plus. What I would suggest if you're going to do unity is go and install Unity by itself. Because it will get the packages you need at that time. Possibly some other things that it has its own installing. Here's what I mean. So that's it. K, you can select Install while downloading or downloadable than install. I liked installed downloading, we gets a little faster. Notice it takes quite a bit of hard drive space. So when we click Install and we wait for it to install, it could take awhile, so we're not going to watch this whole part. And that concludes the installation of Visual Studio. 3. Creating a C Sharp Project: So after Visual Studio's installed, then we'll probably want to do something with it. So to open Visual Studio, after it's installed, yo go to Start and then type Visual Studio urban. Start typing Visual Studio and you should see it in the search menu. And then it pops up. This would no. Shows your recent projects. And it gives you the option to create a new project. Or good a repository that now this is a more advanced topic which we will go over a different day. So for now, let's just create a new project. You'll see that there are many different types of C-sharp templates, template types of projects you can, you can start. So what you'll wanna do, select C-sharp. From this dropdown. I'll platforms Windows. Ok. We're going to do a console application to start. So let's spill the Console App. Select console from this project had dropped down. You'll see there are two different types. There's console app.net core and there's console app.net framework constantly the one you'll want to select as console app.net core because.net framework is the old version of these C-sharp and.net. And you will really want to start with the newest stuff. So to, to create the project, you select console app and then click Next. Let's give it a name. We'll call this basic calc Uli shuns project. So we'll give it a name and then they give you the option to place the solution in project in the same directory. Usually I don't do that because more often than not, I need a different folder for each project and more on projects later. Different types of projects and combining them together. There's a terminology called DLL, which you can basically write things in modules and then combine them together and later in different projects. And more on that later though that's a bit of an advanced topic for, I don't know. Click Create, wave for the project. And there we go. We have successfully created. So Visual Studio, C-sharp project. Just to show you how to run it, you can click this Play button. Now play. Well, we'll run it and I'll show you later how you can debug with it running so that you can see that they ran the application. And they are saying, press any key to close the window basically. So that's how you run the project. There's also another way to run the project, which is to go to debug. Then start without debugging. And now we'll run the project without debugging more on debugging in a few minutes here though, we'll need that a few minutes to debug our program that we're going to make for basic calculations. 4. Variables: Okay, now let's talk about variables and we'll get into actual programming a little bit. So let's say that you wanted to have do calculations on a number. Ok. But how do we tell the program that you have a number that needs to be calculated? That's what's called the variable. A variable can be considered a name with a value. And in the case of C-sharp, it has a type as well. So let's give an example. So let's say you wanted a whole number, k. Let's put a comma in here. I want a whole number that is called AC and has the value of five. So in order to do that, we would put this in tax syntaxes language definition. You can think of it like that. Where int stands for integer. And integers are whole numbers. If you think back to basic mirror, x, i is the variable name equals. Now we have a variable X that has the value of a whole number of five. But say that you wanted to have a decimal point number. Integers are only whole numbers. So if you try to give it a decimal, it will convert it into an integer rounding down to linear standard. So let's say this one that we want a decimal point that is called the access to and has the value of 5.5 mill float. Float is a smaller decimal type number. There are three different types of decimal that you can use. There's float, double and decimal. Float. Float is basically a smallest number. That you can have with the decimal. So we give it to equal 5.05. Then that will be, this represents a float named X2 that has a value of 5.5. F denotes floating point. That's, that's what the F is four here. Now, say you want a, Let's call it the small decimal point. Now was a large slow point. We want to call it at three. Then we're going to use a double X3 equals. We'll just copy this value. Okay? There now we have defined an int, a float, and a double. And likewise, let us do a fixed point, which is decimal. Decimal is great for stuff like dollars, current, the stuff that doesn't need a really long decimal point. It's a fixed decimal points. It has a fixed number of decimal points that it can go out to. So we'll call this four equals five equals 5.6 and M capital M denote death long case. So decimal X4 equals 5.6 means that you have this variable holds a value of 5.6 in the decimal format. Okay? Now though, so that's all well and good. If you only needed a number and you don't need any text, say you need like a name. So in this slide we're gonna do, I want a value. That is a nice thing. Care, campaign letters. So for that, we do string. Okay, let's call it x five. Let's call it name equals the quotation. Here are very important. The quotation denote everything in strings. We can put letters, we can put numbers, we can put special characters. And authors of definite string. So my name is Mr. Josh, firstname, Mr. last name Josh. And now we have a string variable. Please note that you cannot do calculations with strings. You can only do now in calculations, but you can append strings, you can change strings, make them bigger or smaller, and more of that later. So let's see, there's another variable type that I want to show you, which is called boolean value that represents true or false. It is true. So here, this variable named is true. Can only Boolean currently has a value of true or false, and that's it. And it's very useful for logic later. Later you'll see that the program that we're building later in the lesson. So there is one more type that is important, but I'm going to hold off on teaching it few months until later. There's the value of null. And for that you have to have a knowable datatype. So say you wanted a Boolean that had a value of of null or empty, we'll call it equals null. So it's empty. It doesn't have any value to an empty placeholder. So that's a good introduction to variables. Next, we'll talk a little bit about calculations. 5. Calculations: In the last segment, we learned about variable types. This time we're going to learn how to use variable types to do something interesting like calculate the addition or subtraction or multiplication or division of two numbers. And also, I'll end this segment and we're also going to start to introduce the concept of compiler errors. So let's get started. Let's say we have the integer x and we have another integer y. That is to say we want the value of x times y. Simply put first. So first of all, we'll give the variable that, that the value will be assigned to of the multiplication that we put equals the for the first value of the operation, which is times, which is asterix. Why? So with that, we are taking, we are getting the value of X times Y, which will be ten, and assigning it to the value of x times y. And the same is true of the four different things for different operations we're going to use. So X times Y, X divided by Y i plus Y minus Y. So there we've got four different variables. But the results of the four arithmetic calculations. But what if we wanted to do a decimal? Say we've got an integer, okay? And integer value. And we want to, we want to multiply it by a floating point value. So our decimal. So we've got a whole number, we got a decimal. Let's see how that interact with each other. So we'll call this X two plus, plus equals 2x plus x. Now what, what do you think might happen here? So we've got afloat and we were adding acts to x2. So now, if we If we were to run this, let's give it a ride Line. Old outright lied in the light of code you'll use to print to the output window that pops up. Basically what you can think of it as a team plus that, what do you think the result will be? Kidney gets. Alright, let's see. 10.5. Interestingly, in this case, because we're because the one value is a float and the other values and integer and we're only adding, it actually converts the integer to a float and assigns it to the float. Now let's see if we do the same thing with the double X3. Double X3 plus equals X3 plus x. Okay? Now, let's deal with that put out. You'll see that now it puts out 10.55555, which is what we'd expect. Drag because X3, which is 5.55 dot dot, dot plus five is 10.55555. Now, let's say we want to multiply our, get the result x three plus x three plus x two. So these are all fine. There are working very snugly together. Love and 0.0555, just like we would think. Okay, what if we wanted to times they'll work going on here is because these are two different variable types with their both numbers. What is being converted to the other type, like x2 is probably being converted to a double type. And then outputting the type of double from the result of x, sorry, times x two on this one. So we haven't gotten any compilation errors yet, which is good. Everything's working really well together. So now. Let's give a five, the value of the string representation of five to 5.555555. Okay? And we want to do double three plus five. So we don't want to do at 500. Suddenly we're getting an error. This is called a compilation error. When you see this, it means that there's something wrong with the program that needs to be fixed. Something wrong with your code that needs to be fixed in order for it to be able to run. So this is something it doesn't understand. And notice that it says cannot implicitly convert typed string to double. What that means is that this can hold integers and numbers and letters. And well, you can think of it as now holding integers, but think of it as holding characters. So a number, it can be a character. You know, character can be a special character. A character can be a letter, uppercase or lowercase letter. So we could have a BDD 0s at the end of the, now wouldn't really make sense to add to x3, would it? So this, what this is complaining about is it doesn't know what to do with it doesn't know what to do with X3. X4 plus X5, because X5 is not an X5 is not a number. It's a string. It's a, it's a sequence of letters and numbers and special characters. So it's a totally different format than double decimal, float, int or bool. So, and likewise, say we wanted to do It's true. Plus X5 plus five. That's going to mark it up because it's true is a Boolean which can only be true or false. X5 is this big sequence of numbers, letters, and special characters. And quite frankly, the compiler does not know what to do with it. So what we need to do is rethink what we're doing. So is true doesn't make sense to add acts by. Another thing that will throw an error is say, if you try to add a Boolean to death, will double float int. A number type. That will work either because is true, is true, is a Boolean and it can only be true or false. True or false is not necessarily a number. So that's it for calculations and well, very basic calculations. Let's say it gets more complicated than that as well. There's one more thing that I would like to represent it as well, and that is mod mod x mod y. So if you were to take, if you think back to what a remainder was, if you take X divided by Y and there's leftover remainder, then x mod y. The result of this will be the remainder of x divided by y was, and that is denoted with a percent sign to y is x mod y. So in this case, can you guess so it'll be five mod two. Little b. If you think of five divided by two, it's going to be 2.5, right? But the remainder is only one. And that therefore the calculations segment. 6. If Statements: Okay, welcome to the next segment. We're going to talk about if statements. So you'll see in the program, here in the code, we have a variable representing the number of red jars. A variable representing the number of green jars. That a variable representing the greater number of jars. So how would we create an if statement to determine if there are more red jars or green jars. Let's look at that. So if if statements starts with an if and a parentheses, and then you have your conditional statement. So for instance, if number of red jars is greater than number of green jars. And the curly braces here important. It denotes where the if statement starts and where the if statement ends with the closing, opening and closing curly braces. So in that case we're going to do Grey turn number of jars equals number of red chars. Else if K. So this is the second scenario where the number of red or green jars, It's greater than the number red jars. Then we set the greater number of jars equal to number of green jobs. Helps the two are equal. Because if number of jars is not greater than the number of green jars and number of green jobs is not greater than number of red chars. That means they're equal in this case. So who do greater number of chars equals either one would work number of red cars in this case. Let's do that. Also. C. Now let's do, let's also add a console right line for each one of them. Okay. So we'll step through this in a moment so that he can see the program flow. Then let's output the number of Greater jars. The greater number of chars. To clarify which, which, what number has a great, what number is the greater number? Create an if statement. Okay, next we're going to create an if statement to determine if there are less red jars or less green chars. So it's the same thing, but we're just going to do less than instead. So if number of red jars is great, less than number of green jars, then console, dot, write line less bread. Lps. If number of chars, member, read chars. Then we write to the console more plus, plus, plus. And then announce again. Lps console, dot, write line. Then finally, let's create an if statement to see if they're equal. Bread jars. Z equal number of green jars. To output again. A murmur of chars. Let's add one more. Let's do one for not equal number of chars, not equal number of green jars. Then we'll put not equal number of jars. And then we'll do one more thing. We'll create one to see if to determine if there are if the green jars or the bread jars per plus 0. How will do another if statement, addition to determine if the green jars and jars or less than 0. So how would we denote? That? Is we say if green chars, number of green jars is less than 0, or number of bread jars is less than 0. Then we're going to output the number of green or red plus 0. So let's make this negative ten. If number of bringing jars is less than 0 and number of red jars plus sin 0. Then let's put out instead of four bell. Let's see this in the debugger. Start by setting a breakpoint. Next, let's step through the program and we'll go step-by-step and see how the program executes. So currently number of red jars has number negative ten. And we're agreeing jars has 20. Greater number of jars have 0. Can you tell which of these three? The program is going to step into next? So the number of red jars is obviously not greater than the number of green jars because it's negative. And the number of green jars is positive. So it's going to skip that one. Number of green jars is greater than number of red jars. So it's going to step into here. It's going to set the greater number of jars to number of green jars. Then output green is greater. Then it will output the number of Curator of chars. So in our console, this is what a console looks like now and yeah, I'll put it to output, Greenleaf, crater and 20 because it had this console dot write line. And they hit this console that right party, which the greater number of jars is 20 current. Next, we're gonna do less than, so. If number of thread jars, less than, number of grain jars, which is true because number of red jars is less than 0 and number of green jobs as positive. It's going to output less red. If number of red jars is equal to number of green chars. Sick gonna step in here no, because they're not equal. They're different numbers. And then if number of red jars is not equal to number of green chars, then we'll output not equal number of jars. So now this is what our console looks like. Green greater 20, less red, not equal number of jars. And then finally, if number of green jars is less than 0, or number of red jars is less than 0. So number of jars, number of red gyres is less than 0. But number of grit green jars is not less than 0. But since this is an or, if either one of these is true, it will step into this. So number of green or number of red less than 0. Now for this one, number of green jars less than 0 and number of bread jars less than 0. So they both have to be true for it to step into here. So number Green jars is not less than 0. So one of them is not true. So it's going to skip over that. And that's it for if statements and introduction to if statements. 7. Arrays and Lists: Okay, next let's talk about arrays and integers. Let's say he wanted to create a variable that represents a whole bunch of numbers, say a 100 thousand or even enough. You need a million numbers saved, got a million bank accounts K. You don't wanna make a variable for each individual bank account, right? Like account balance. One. Account balance too. Okay. Probably we don't want, we don't want a separate variable because when we get to million, this is gonna get really cumbersome and might take a long time to write a million of these out and then managing them would be the more difficult, right? What if we just wanted to do it in one line? So that's where arrays and lists come in. So int square bracket dot represents a ray. We'll call this account balances equals new int 1 million. But right now we have a variable that 1 million integers. And how do we use that? Let's set some values in the array. So we have counterbalances 0, K. This denotes the first element equals. Let's set it to one. Let's say the first bank account has 100 actually. To small banking Carol come down account balances. The second element equals 120. And the third element. But say, let's say this equals the sum of the first and the second for some reason. So let's say account balances 0 plus Carol balances one. So this side is the is where you're signing the result to. So account balances, the second element will get the value of what is on the right hand side of the equal sign. So account balances 0, which is 100 currently because we add, we set it to 100 plus account balances one, which is 120. So that's going to be 220. Now let's create and do the same thing with the list. A list of integers is a little more dynamic. So to the final list to do list, then less than, greater than r, whatever the type, this would be the variable types. So if you wanted a float, then it could be a float. But whatever you put here has to be the same here, the compiler will throw an error at you. So Float or double. We can make it a double or a string. And there are other types that we can set to, set it to as well. But for now let's just set it to an integer. Okay? Now let's add the same things we added up above. But this time we add them to the list one by one. So each time one gets out it, it gets added to the end of the list. So this'll be the 0th element, this will be the first element, and so on and so forth. So lists of balances dot add. And we're going to do list of balances, 0 plus list balances one. Can we see, kind of see that this line is very similar to this line. It adds the second element of the list down here. The third element actually 1-2-3, and gets the value of the first element, the 0th element, and then it adds the value of the first element. So it's also going to be, so we're going to add the result of this to the list of balances. So it'll be one hundred and one hundred twenty and then to 20 down here again. Let's do the same thing for strings. So let's create an array of strings. Will do a 100 and strings this time instead of a million. Then we'll, we'll have the first name. Equal. Might well have this second name. Equal. Julie. And we'll have the third name. Be the concatenation of the two. So Names 0, Mike, that's going to be Mike plus. So this is going to make, this is going to set names to the third index, two names, 0, which is my name's 0. And then it's going to add a space. And it's going to add names one. And it's going to assign it to the third element in names. And the array of needs. We'll see that in the debugger moment here. Then let's do this same thing with list and a string. Now, we'll add the same things. 0 or actually, let's actually denote it the same way we did about Mike. List of names dot Julie, list of names, dot add names. The firstname, which is Mike, plus space plus list of names. One. In fact, there are two lists of names. Now let's step through it in the debugger. So when we look at this in the debugger, will notice that account balances, well, it's going to start out as null before we set the value k. Then we set the first element in the array. You can see that they're all set to 01 through a million. I mean, I'm not going to scale to a million that are take forever, but it sets all the numbers in the array from 0 to a million Alda 0. Then we set the first element, the 0th element in the array represents the first element. So the first element is 100, the second element. And then you can see that it sets, that it set the first element 200 here. But it hasn't set the next one because we haven't run that line of code yet. So 120. Now we'll see that account balances has one hundred and one hundred twenty because we set the 0 first element. And then we're gonna see that. The second element, which is currently this one, see how it says two matching with this. The second element is going to be this, the addition of this and this. So after this line now becomes to 20, but all the others are still 0 because we need to set them to something to have it do anything. Same thing with the list. As we live, as we add to the list. You'll notice that. Let's do that again. So when we first create the list, there's a count of 0. And then as we add each one, the count goes up. Because what the difference with training array and a list is that with an array, you are creating the number of variables up front. So this creates a million integers space for a million integers up front. This one has the capability to add a million integers, but it will add them one at a time. So, so you can see the count is one and all that's in the list after adding 100 and is only 100. Which if we look back at the array, all the numbers are there. From 0, from indexes 0 to a million. But you, you, with a list, it's more dynamic because you'll be able to just add one at a time as many as you need, not not doing more than you need necessarily. So one hundred, one hundred and twenty. So you can see that count got raised to two as one hundred and one hundred twenty. And then it's going to add them, add the 0th element and the first element together. He noted by this and this, and it's going to set them, add them to the list, which becomes this third element to 20. So 00. Arrays and lists are zero-based. That means the element that you're at, like 012. This is really the, you could say this is the first element or the 0th element. And people understand what you need. First element or the 0th element, second element or the first element, depending on how you're referring to it. People usually understand, but usually you want to say the 0th element, the first element and the second element for the, for this particular array or list. Now, this time we're going to add list of strings and see that all of the other variables in the list of strings is null. That means, all that really means is it says the computer has space to put something there, but nothing has been put there yet. That's kinda what null means. So, so we set the 0th element of Mike. We set the first element, did Julie. But we haven't set the second element yet. Then name to it will set the concatenation of names 0 plus space plus names one, which comes out to be Mike Duly. Can you see why that is we had named 0, which the 0th element is Mike, names one, the first element is Julie. So does named 0 plus space plus two plus names. One, mike, Julie. Okay. Then down here, we did the same thing except when you first create the list of names. Once again, the count will be 0. And then we add things one at a time instead of there being a 100 variables this time. Thoroughly, we add them dynamically one at a time. So mike, then you see the count goes up again to two because we added Mike and Julie. And then we're adding the same thing similar to up here but with the list of names, 0, lists of names, zeros Mike plus space plus lists of names, one, which is Julie. And then so we'll have Mike, Julie, Mike Duly again. And that's it for this lesson. 8. Loops: Okay, next we're going to talk about loops. So before we get started, I have created a list of balances similar to in our last lesson with a list. And we've added the values 100121, eleven hundred one hundred fifty, one hundred five thousand plus lists of balances. The first list of balances in the list, so 100, and the second list of balance, no noise which is 120. So what we'd like to do first, let's add all of the balances on the list together and put the, put the value in total balance. But not using any loop. So we'll see how inefficient that is, just doing it one by one. So, so it would start out, we've already created, created the tunnel balance failure variable. And we'll add the list of balances. The 0th element, which will be the 100. Then we'll add list of balances. One, which is the one-to-many. Then we'll do the same thing for 345. Are 234 other zero'th element, first element, second element, third arm. Report that. So that's all of them. Oh, there's one more actually. 65. So we, but we output, this will be the same result as in the other two loops we're going to create. But what if we had a million entries in our list? We'll do it wanted to type 012345 all the way to a million and so on and so forth. And what if their ability, and then I might take a really long time, right? Hence the need for a loop. So at the end of this, I'm going to reset total balance, set it to 0, so that for this part, it's starting over. Now for a while loop, the syntax always starts with wild. Well, there's a do-while as well, but I'm not gonna get into that because most people don't use that very often. So while, and then we have our conditional statement. So while and in our case, it's going to be element number we are on, which starts out as 0. We've created this element number, we are on variable. That's going to start out as 0. While element number where I'm and less is less than list of balances dot. Then all we're going to do is told balance equals plus, equals TO mental list of balances. Element number we're on. Now, this, as we'll see in the debugger in a moment, is the equivalent to all of this. Actually, this is the equivalent to all of this. So I think it'll make more sense when we step through it in the debugger. So give me a moment. Let's, let's put out the rest of the code for the for loops that we're going to create. And then I'll show you in the debugger. So next, we have four. So the syntax for a for loop is for k. And that could be any variable type. It doesn't have to be at. We're just declaring a variable that is similar to this element number we're on, we're just going to call it I. This time the variable i equals 0. I is less than lists of balances dot Carol, I plus, plus. So how the flow, while a for-in loop goes is first it's gonna create the desk variable. When it starts the for loop. That's going to check if this is true. If this is true, will go into the for loop and do the calculation we're going to do, which is total balance plus equals list of balances either this time instead of element number we're on. We can't forget to reset total mounts to 0 before we do that. Otherwise will have twice the number of the sum of all beads. So TO balance plus equals list of balances I. So then it's going to run this line of code. Then it's going to go back up to here, check it, and then it's going to increment i, do i equals i plus one. So after r equals 0 it will be one. Then it will check if i is less than list imbalances dot count, which was to bounces dot-com is 123456. Right? And then it will continue that and continue going in the loop and tell this is false. Till i is greater than or equal to less imbalances. Cow town. Then it will exit the loop. And we'll see that all of these outputs will be the same. And then there is one more type that I would like to present, and that's a for each loop. So what we do here, for the list of balances, It's going to be, this is going to be similar to this. But we can't do, I gotta do. For each element. I got that wrong. Let's see. For each element is what I meant to say. And then we sum each element. And what this does is it will get each value in each step of the for-each loop. So let's start with the value 100. And then we'll add 100 and the total balance, then it'll add the nets. Then it'll go get the next integer element in the list of balances. And it will add that to the total balance and so on and so forth. So this will be the same. Last but not least, let's display all of the names just to show that the syntax is the same. For outputting strings. So for lists of strings, so for and i equals 0, i is less than lists of names, dot count, high, plus, plus. And when you're creating your for loops, don't forget the semicolon. This, this signifies the end of the declaration part of the statement. This signifies the end of the conditional part of the statement. Where if it's true, it'll go in and if it's false, it'll skip past it. And this is the increments part. So then we do console dot, write line list of names pi k. Now let's run it and see how it executes. So let us start with this slide. So let's do balances, list. It's going to add each one in lists of 0th element is 100, so we just added 100 and the total balance. Then, total bounds plus equals 120, which is the first element in the list. And so on and so forth. So it's going to add each one individually. The TLA valence ends up of all the accounts equals 107,590. And we're going to output that to the console. And that's what puts out. Then we're going to set tell bounce equal to 0 again so we can step through and add them through a while loop. So one thing I forgot about this is that we need to increment the element number we are on. Similar to the four-loop. This, This is similar to this in the for loop. So element number we're on increments each time we're going through. And Intel, it's greater than the number of the number of integers in the list of balances. It will keep doing this while loop. So lets continue on. So while element number we're on, which is 0, is less than number of list of balances dot count. So zeros less than six, right? So. Into the while loop. And it'll add the element number we are on, which is 02 TO bounce. And then it'll increment the element number we are on. Now it'll check if element number we're see how loops back up to the top of the while loop. That's how the loop, that's why it's called a loop because it goes in a circular pattern until it's done. Then element number we're on now is one. Form is still less than six, so we go into the while loop. And then total balance plus equals list of balance is element number we are on, which is now 120. So it's going to equal what's currently in the tone balance plus 120, which is 220. Then it increments the element number we are on again. Now it goes back in the circular pattern. Element number Iran is to now, which is less than count. So we step into the loop again. We add the next balance, K, Then we increment the number we're on. Three is less than six. So element number we are on as less than L2 balances dot count still. So we get the third element in the list. Then I'm going to skip through a couple of times until we get to six. Now element, where on this six we've got the total balance. So we had on the previous, on the previous example here. And after the while loop is finished, meaning that this condition is no longer true, it's false. So element we're on is six, which is not less than six. So the element number we're on is not less than the count, the number of elements in the list. So it'll step over it. I'll put the current bound, the total balance, which is the same as the previous one. Then k. So for them until then, we're on to our for loop now. So for-in loop is very similar to a while loop. It just has a place where you can instantiate variables, which is this part. And most people use for or for each Most of the time. It depends though. So for int i equals 0, so R is going to be 0. Then it's going to check if i is less than the number, the list of balances dot count, so 0 is less than six. That's true. So we're gonna step in here. Now, this one run until after, until the next iteration in our loop. Because it checks this first. How, how the flow goes is it sets this out, checks this. Then we'll go into here if it's true or skip out of its faults. And if it's true, then we'll do, we'll execute the statements inside the brackets, the curly braces. And now you'll see it goes up to here. So incorrect. It'll do this part where it increments. Our ads won't ads whatever he does, whatever you put here. Next. So now i is currently 0. After this line i is going to be one. And then one is still less than six. So it's going to step in again. It'll get the second balance. Then we'll step into here again. It will increment i again. So i is now 22 is still less than the list of balances dot count. And then total balance plus equals list amounts as again, which is, this is the 1100. So 1320 is the total of the first three summing, and so on and so forth. So a global do that until I, until this is no longer true, which until i is six, it will, this will always be true. So we'll keep incrementing. And then when i is six, its steps out of the loop. And we're going to output the total bounds one last time. K. Now let's do the Fourier. So the foreach will grab each element in the list, but we don't have to index it like this. Well, we have to do is assign. This is saying this is equivalent to this with the, with the i ith element. So it's going to grab each element one at a time in the list. And that is going to go and tell there's no more circular loop. And then it's going to execute what's inside. So the first element is 100 as window. So the first element is 100. Then the total balance will plus equal the element. So it'll be 100. And then get the next element, which is 120, which we can see here. This second element is 120. Or the first element will have you wanted to say it. And then the next element is 1100. So it doesn't have a conditional statement. You'll notice it just goes through each of the values in this list of balances and runs this code for each element in the list of balances variable. That's how for-each works. And then after it, it kinda keeps track of where you're at in the loop. And then when there's no more elements left, then it will exit the Fourier. So you can see that they're all equivalent. The, the four different loops. It's just a matter of how you want to perform the operation that you're trying to do. And last but not least, we're just gonna do the same thing we did above. But we're going to output the list of names in a loop. So we're gonna set i equal to 0, while i is less than lists the names dot count and there's three names, 123, i plus, plus, no way i plus, plus then a run until after this slide. So list of names, 0, right? Is Mike. So it is going to output. Then it's going to increment this. Next. It's going to run this statement. Then if this is true, then it will step into the if statement, which one is less than three still? So we step in to Lee. And then so i is still less than count. So we're going to output the second element. Visual Studio, how to bug them some sort of for a moment here and run this again. One moment. At the end of the loop, we'll have Mike, which is what we're expecting and that's it. That's my Intro to loops. 9. Intro To Functions: Okay, so for this next segment, I'm going to talk about functions. Now. Many of you might already know functions. So if you know functions already, feel free to skip on to the next course. So a lot of good coding is about organization of code and naming of things so that people can read and understand what you're turning to do. Like for instance, let's take, take the idea of adding two numbers over and over again. We could do. We have these three sets of numbers here, x, y, x2y2, and X3, Y3. Let's say that you want to add the result and put them into a z variable for each one. Well, one way we can do it is we can do z equals x plus y. And z two equals X2 plus Y2. Z3 equals X3 plus Y3. Okay. That's all well and good. But let's say that that chunk of code is not just x plus y. It's a chunk of code that does something like calculates compound interest or something like that. That's going to be a little bit more code and you don't want to copy and paste that all over the place, right? Because it's a lot of code. If you can have all that code of one place, then that would be better than copying and pasting it all over the place. Hence the need for functions. So we're going to call up, make a function in this case for create, adding to them. This is the most simple case of a function, but so you might not see the actual value of it yet. But when you get huge functions are huge sets of code. It rarely will make more sense steel later on. So add two numbers, x, y. So we're going to return, all this function does is return x plus y. And in fact, we don't need to call this x and y. We could call it paid BY peanut butter one and peanut butter two. Whenever we want to call it. Let's do a, B, C. Don't get confused with this X and Y down here when we call the function. So what we're gonna do, so the way the function is structured, don't worry about this static. The other reason we have to put static here in this case is because we're calling it from a static, another static function which is made. But in most cases your function should not be static. So let's write this without the static actually. So most of you are functions will look like public and add two numbers, Baumol, blog and public and private later when we get an classes, but you'll see more of that in a minute in the next upcoming courses. So for add two numbers and return a plus b, k. And the return value is an integer. And we wanted to be an integer because we're adding two integer variables. We could also, Let's do this. What if we wanted to create another function for simplicity for adding two numbers that are floats. If you recall, floats are a decimal point. But for so you can see that the structure is the same for adding remembers it's just setting the variable types, deferring. This, this return, this type in front of the name of the function. This is the name of the functions. Add two numbers int and add two numbers float for the names of the functions. And this variable, this value in front of it or this variable type in front of it will tell you what the function is returning. So now instead of x, y, we can do this. Add two numbers in x comma y, two members in X2, Y2. And won't make these floats. So we'll call this function, add two numbers, x 33. And then why don't we create one more function? Output the result. So the return value will be void because all we're doing is writing to the command line. For each one of these. So void means it's not returning any value. When you return a value, it means you can set, do something like int z or in peanut butter or whatever your variable name is, set it equal to the value that the function is returning. So in this case, it's going to return the sum of the two variables and assign it to z. And then it's going to assign these, sum, these two variables when it gets into here, return that value and then it'll go into z2 out. That makes sense. So now Let's see. And what we're going to do is console dot write line value. And now for at the very end, we'll output the result z. Two. Let's make one for our result. In an output result, float actually V times we have two different variable types. Smell when the program executes. So what's going to happen is first it's gonna set the values. So x will be five, y will be three after we run these two lines. And then when we call this function, the program execution is going to stop here. It's going to pass x and y in to a and b. Then that's going to jump from here up to where the function is defined. And it's going to now do calculations with the values you passed in. Here. Remember x was five and y was three. Well now a, a was x is the first variable t0 passed in, so that becomes the first variable in the list here. So if it becomes five and B becomes three, then when we return a plus b, it's going to be eight. So and the return values and integer. So we can assign the return value of the function to the value that you want to hold the value, the result of the function. So in this case z, we called it z. Then the same thing. X2y2 gets set. Then we pass in 79 for a and b. So 79, because x2 is, x2 is seven, Y2 is nine. So a becomes a becomes that variable, and b becomes Y2, whatever was passed in as the second variable, pen. So a plus b is obviously 16. So then we get 16. This time it's going to jump to add two numbers float because we called the float function instead of the function. And that's 4217 plus 25. Now, when we call output result, it'll call the command line first, the command lines blank. So then we step over that line. The Quran line becomes eight. Then you step into this function again. Remember it's not returning anything in this case, there's no return value. There's no return variable type. So like when it's boyd, We don't have to return anything like we do in if we did finally dense float, we have to return a float. You find the function is integer, we have to return an integer k. So then, then we're going to output the result of Z2, which is 16. Actually I'll put 16. Then it'll output the result of S3, which is 42. That's a very brief introduction of functions. I hope that helps new people starting out to some degree. Understand when a function is. Thank you for watching and now we're gonna move on to the next segment. 10. Classes Part 1: Hello and welcome to our next segment, this class, we are going to talk about classes. So basically in a nutshell of classes, a container for variables and functions that do. And they usually, usually they're container for common themes stuff. So I, in this case, we're gonna create a class, created a class called arithmetic operations with variable x and variable y that are both integers. So if we want to write up a common function to the arithmetic operations class, all we have to do. First declared public. Luca will put the return type of the function is. And we'll do had, had this all this time. We're not going to Paris in any parameters though. Because the proud variables or within the class itself. So that we've already said, where do you have those values? So in this case, we'll just return to x plus y k. Now, to actually use this class, well, we need to do is create an instance. And we create an instance of the class we just created. So we'll type arithmetic operations, which is the name of the class. We'll give it a variable name. Because now it's a variable equals new arithmetic operations. If you don't do the equals mu, the class will not do anything. It'll crash the program if you turn to ease it. So remember two equals new, but the type that you're creating. And so now to use it, one way the use it is we could do a tick operations dot x five. So say we want x and y to be 53 respectively. So we set, set the variable types. We set the variables x and y to 53. And then we're going to do arithmetic operations. And the result x comma y. Know why? Because it's RDD x and y already you find within the class itself. Okay? Now, if we were to do z equals that result, then we get a console. Right line, x0. And x0 would be the result of five plus three. After this all runs. Now, another thing that I'd like to introduce you to in this concept of classes is constructors. So let's say that when we initialize one, we instantiate the class, which when we knew it up. This is called moving it up in a science. When we create a new instance of the class, we might want to, we might, we might not want to set the variables after my mom is set the variables as part of the instantiation of the object. So instead of setting 53 there, we'll set, we'll, we'll set it in the constructor. All of the constructor is really for its, Think of it like a function that happens when the class gets created, instantiated. And basically or does, it really does, is it's a way to instantiate variables. So it's, it's like a place where you put all your initialization very often. So, so for instance, in this case, we're passing in 53 when this gets created. And now we'll set x equal to x2, y equal to Y2. Which acts is in our class, y is in our class. 53 get passed to X2 and Y2 K when that, when it's being created instantiated. So now we have a class with the constructor. The constructor has no return type. I forgot to mention. Not even void or anything. You just don't put a return type or it knows it's a constructor. We could also have multiple different constructors. So say we only wanted to set the x variable. Then to call, this is called, I believe, overloading. So over in the constructor, overloading the constructor. So if we want to call this one, we would just call it a. Since this only has one parameter, we just call it with one parameter. The full 100 call with 21, with two parameters, we just give it two parameters. So another concept that I would like to introduce you to, in addition to all, this is the basic concept of interfaces. So we have, we'll create a public interface. Usually women create an interface, hits. It's usually starts with the interface name, starts with the NIH, and then it's the name of the class that you're creating, usually the interface for. So emit pragmatic operations. And all this is, this is kinda like a stub of what you're going to create. So we won't put the constructor in there because it doesn't have any idea what the constructor is. We'll, we'll, we'll just add the function in the interface for now. And we don't have to put public, private or protected because It's already set out here. When you're defining the interface, it's already public, private or protected. Now, let's talk about public, private and protected. So if you have a private variable k, it can only be accessed within the operations of this class. So we can't do stuff like, like we're doing a minute ago, which is arithmetic operations dot x equals five. And because we made x private, here, we cannot access that outside of the class definition. We can only access public, public ones. Now protected. I will get into in the next segment, but that's all other protected is like if you inherit from this class, which I'll get into later. If you inherit from arithmetic operations, then you can access the protected, the protected variables of whatever you're inheriting. But more on that in the next course. So don't worry about that. For now. Snowy have an interface with arithmetic operations. And we want to say that the arithmetic operations class implements have really been to corporations. So now, anything we created here, like if we created another function called it multiply result. Now, this is going to give a compiler because it doesn't impulse, because we haven't implemented multiply result. So if we go in here and we go public, and there has to be public in this case, because the interface is public. If the interface is public, all the functions that you do fine in class that are defined in the also defined in the interface have to be public as well. So public multiply and public int multiply. Result nosy kinda imagine what we would do, return x times y on that. So the last concept that I'd like to introduce you to is the concept of properties. So in different languages, you will, you'll create a get NSSet function and keep most of your variables private. So then he said, So for instance, who do in other languages like C plus, plus a lot of times w is Paula again, get X, and then that will return x. Because x is private, we can access it outside of the class. That makes it so we can't edit ads, but we can still get access if we need it. But C-sharp has made a more simplistic way to create a getter and setter. But In this case though, we still won't be able to access. This is the getter and setter outside the class because we've centered as private, we would have to set it as public. And inside of the properties. We can define other things as well if we would like. Let's see, whoops. So say we always want an adversary term five. When we set x. T's. In this case, we don't want you to do anything because it's always returning five. Well, why don't we have a variable private, private equals five. Then we can return the private instance of this variable through the get, so we can access it here. So we're not actually touching the private variable until we except through the property. And then we can also do private X equals value when it's set. So the equivalent of this is if we're out here in Maine and we do arithmetic operations, dot x, x is now a property. C, you can get it or you can set it. If we do x equals five, that we'll call the set. If we do just hermeneutic operations dot x, C, x2 equals arithmetic operations dot x. Then this property will call just to get. But if you call the set that is called the, if you set it equal to something else set, it'll call the set with this function, so to speak. With this property definition. Last but not least, let's define the property of X as part of our interface. So that we can use, use the variable x when we are using just the arithmetic operations. So just to recap what we've done, we created in a public interface. With an ADT property in that it has a getter and setter. And we've created two functions and odd result and int multiply result to two place holders for the function. For the different functions. Then we've, we've, we've, let's see. We've implemented the interface with arithmetic operations class. And in that we've defined, we have defined X as a property in both the interface and in the class. When you do the get and will return private acts. When you do the senate, who will set private acts to the value that you set it to on the right side of the equals. We've talked about. Constructors. Constructors are basically initialization functions that when you instantiate the class by doing new, you can pass in different parameters so that it will, then, it'll then pass those parameters and see you can initialize different variables within your class that are private or whatever you wanna do with that. Then we created two functions within the arithmetic operations. Two stubs in the interface and define them in the class. So that one get a compiler. And at the very end, we call it z. Z2 will say rithmetic operation. We called the two different functions, which is add and multiply result. And so now when we output Z1 and Z2, when we run this, you see that it returns the result of five plus three, which we set in the constructor for x and y, which we called the Add Result function, which will do x plus y. So it's five plus three. Now we do the multiply result, which caused the multiply result function, which is five times three, which is 15. And that's, that's a basic introduction to classes. The next lecture, I am going to talk about object-oriented programming a little bit and introduce you to that concept. 11. Classes Part 2: All right, welcome back to the last segment. We talked about classes and the months basic sense. Now, we're going to talk a little bit about class libraries. And then we're going to talk about object-oriented programming. So let's start with class libraries. A class library as a container for classes within C-Sharp Visual Studio projects. So if we right-click on solution and we go Add New Project. Who would want to go for c-sharp? We wanted which we scroll down. Let's do dominant standard class library because that's the most important rule. And we will call this parenchymal ten operations. So now you're nervous in the solution. Now there's the basic calculations program, project, which has our our current code with me and everything. And now we also have another, another project which is the arithmetic operations library. Pick. It created a default class boards. So this is just kind of a container for classes is one way to think about it. So let's see. Let's start by moving. Our interfaces. Are interface over here. So mu, we'll call this. We'll, we'll just click yes or no on the popup that pops up to rename the class from class 12 arithmetic operations. But we're gonna override it in this case, it doesn't matter what we swapped. So now we have our interface per lunatic operations that we're going to create a class. Or in the nation's blacks. Human Go program. Copy our entire plots or into corporations, get rid of this extra whites. Okay, so now, now we've successfully included created primitive operations library with our arithmetic operations class that implements our higher arithmetic operations interface. Now, to use, to use this and are the class, you'll see that arithmetic operations has a compiler. Now we can no longer do find in here. We have two. Move the project we just created as a project reference. So we'd go out and project preference on the project over here. And then we do. Then we left-click on the new library, which is or a lookup arithmetic operations Library. Click OK. Okay, and so that makes it so we can see the project. But now, in order to use the project, in addition to that, we have to introduce the concept of namespaces. So the reason why namespace, and I'll start with the reason why namespaces exist. Namespaces exist because say you have two different classes called mat and they're in two tones, separate files. How do you tell one from the other? And that's where namespaces committed. So if we have one that's arithmetic operations library, TopBack or something, or if we have arithmetic operations by Lindemann in another file, we can, we can separate the two and definitions and know what they're doing. And we don't know which one we're dividing by the namespace. So there are two ways that we can use the namespace, which is type out the entire namespace to pop operations library dot. Now, let's copy this. Now that gets rid of our compiler. So next, we want to see, next I wanna show you how you can do it without specifying the namespace Arrow-Debreu Singleton. And basically what you do is you type using and the namespace name, and then put a semicolon at the very top of the file. Now, anywhere that we're using something within that arithmetic operations library. Pill. No, what? We're using a using statement. So that's just like using it for everything in this class, but uses the arithmetic operations library. So r in this file, rather not as soon as class because we can have multiple classes within a file as we've seen. Now, the next thing I want to show is the concept Object-oriented programming. So most basic sense is that we have created at the interface. For it our last lesson four arithmetic operations. That has an integer x. Though we have an integer y in the class, but we have not defined it as a property. So we can see that in the interface yet, which I'll show you what that means. Ad results could multiply result. So those are, those are, well, we can actually see only, only instantiate a when we make a variable of type II arithmetic operations, we can instantiate anything that implements that interface. So because because arithmetic operations is implementing the arithmetic operations interface, we can now instead of, instead of, instead of putting our arithmetic, arithmetic operations equals new arithmetic operations everywhere. Now we can put II arithmetic operations and we can actually define different types of arithmetic operation. So we have no arithmetic operations. One and arithmetic operations to as the most basic example. So we implement that carry. Well, I'll just, I'll just put a place holder for everything. These this is a different concept. Throw. Don't worry about that right now. Just know that we are creating a class that implements the arithmetic operations in the most basic sense and doesn't have the implementation. So if we go back to program, we can now say I arithmetic operations are arithmetic operations equals nu. Arithmetic operations, or we can say equals new and the tick operations too. But we haven't defined the constructor and arithmetic operations to, so we have to get rid of the parameters to the constructor in that case. So basically, if I wanted to do so this so these are two different implementations. These are two different implementations, but they have the same signatures. We mean they've both implement, Have a hover property index with a getter and setter. They both have bad results. They bought them multiply result. It might not do it again because operations to doesn't actually do any fees have crash right now. But we have the option to define different types implementations or the same interface is what I'm getting at here. Now, let me also, let me also include the concept that the abstract class. So there's classes and there's abstract classes. Have an abstract class is very similar to an ACK reinstantiated. But you can and interfaces you can not implement any of the functions. But in an abstract class you can implement the functions. You just can create a new instance of the abstract class. You can only create an instance of the of an implement of something that inherits from the abstract class. So let me show you what that means. So if we do have stripes, are written operations. So we'll start here. We'll do public class abstractor analytic operations and implements IEEE arithmetic operations. Now, we have the choice on simple linear, basic stellar this again, we have the choice would this to not define any of these? So we can just put, and the way to do that is we put public. Abstract in had result. Ah, we have to name the class that we abstract. And there's a way that in addition to that evening to override it, kinda the implementation. So what do we do there is we call it Burke tool. So abstract means it doesn't have a definition yet. It's just a stub paddle-like in meter base virtual. You can actually have the implementation and then have a different implementation in something that inherits this class. So in here we might wanna do return x times three, or x times something, as we would think, because it's multiply result. Now, let's, let's no longer buts known or implement the interface. Let's inherit the abstract class now. K. Now we've inherited the abstract class. But we mean by now. In order for this to compile, we need to, because the odd result function P and that arithmetic operation, or deny the abstract arithmetic operations. Because the result is abstract, We have to override it, overrides the implementation to to have it actually compiled. So an add result will do return x plus y k and multiply result. We'll have a do return X plus X times or. So. See how this definition is different than when the abstract. But we've forgot one thing. We either have to call this work to own or we have to overwrite it more particularly what override it in this case, because we're creating a different definition of the virtual of the thing that was virtual. Now. We can also get rid of this and it will still compile. So if we compile it, step we need to get rid of, needs to patents. So you can see it compiles still. When I took out the, I just took out the function or multiply result. And it still compiles. Why is that? The reason why is that in arithmetic operations, abstract arithmetic operations, we have already defined a virtual, a virtual representation of multiply result. So we don't have, we don't have to define multiply, result many. But we can override it if we wanted to do a different implementation for some reason. So that's a virtual of abstract are abstract is that you, you have to implement it in a subclass to not implement function in the abstract class. If it's abstract virtual, you can create a base, base implementation of the class. And then overriding in here like we are doing before. So this is actually overriding the multiply result that was in the abstract and threaten to corporations. So can just a minute, we'll do a recap as well. So so let's say we want. But I'm going to also introduce the concept of base here. So say we have multiplier is old. Okay, go we wanna do the base implementation of multiply result before running our, before, after running our code. So do base out multiply result. I'm based out multiply result. Well then called the base class. Because we're in, because we're inheriting from abstract arithmetic operations. We were calling based out multiply result, which we'll call this multiply result first because it's virtual. None, we're overriding that with x times four. So the, so what it'll do is it'll do this verse that's ten Siri, return x times three and let it, it'll return it stands for. But if we actually wanted it to change, who've got really do x times equals, sorry. Return. Because otherwise we're just returning the value. But we're not using the result. Who must we use unless within something like this, where x2, x2, x times x2 or something like that. So, so that's how you use them, base plots of the abstract. Then you are inheriting. There's one last thing though, weather data. I don't want to show it, introduce you to that site. You go to have an abstract class too. You don't have to have an abstract class to inherit from a class. All you, all you really need is a class itself. And they both, I think, I'm pretty sure. Let's see. If we get rid of this here. Okay? Then we can have arithmetic operations, implement operations to k. And now the only thing we need to change here is we need to override the different types. So will give us, so give us a morning. Also if we don't override the ints class, it'll just do what the base class does. The base implementation does, which is not necessarily what we want in every case. Last but not least, because this is inheriting operations. Oh, yeah. Also the property we need to let's see. Well, let's just say now that we know that we've got the base class, a base class for this, this, and this already has a definition or packs. Penn. We're also going to create a definition for y. And we're gonna make that protected. Remember how I said that protected? You can only, you can only see it. If you can only see protected variables if they are in a class that's inheriting this class. So abstract arithmetic operations to inherits abstract arithmetic operations. Arithmetic operations implements or inherits from arithmetic operations to. So this, now arithmetic operations will get everything that was the proven we took operations to penned paradigmatic operations two will have everything though as defined in the abstract arithmetic operations. And we still are implementing near face or high arithmetic operations on the base of it all. That is a basic introduction to, I've basically gave an introduction to differ how to use different different types of abstract interfaces. Overriding functions that are inherited. Also, we went over a little bit more protected variables. And how to use the base class based implementation of something if you have, if you wanted to override it, or if you just want to use the base implementation. So I hope that helps, helps you to understand the basic concept of classes a little bit better in abstract classes and how to, how to use object-oriented programming a little bit. Thanks for watching. 12. Installing Sql 2019 Express Edition: Okay, welcome to the next section. For this section we're going to talk about how to install SQL Server 2019 express edition. The first thing you have to do is go to Microsoft's website and download the installer and open it up. You can either do Developer Edition or express edition. If you are a developer will give me everything. Developer Edition. Express edition comes with a subset of things with an also it's limited to ten gigabytes. I've lever, uh, used to be ten good ride center node. It is right now of storage space and then you have to start paying. So but for the purposes of this course, you can download either will be fine because we're not going to use that much data. So once we get into as SQL Server 2019 express edition are usually clicks. And you can change the PDF download target location if you'd like. I usually just keep that the same click Install and won't download that quickly for you because I have previously installed it in another instance. That's why I installed so fast for me. The installer. So it's installing the installer, which sounds funny, but That's what it is. So then we go to, first, let's install a new SQL Server stand-alone Yiddish installation. K, we click that, keeps popping things outside of our little one down here. K. There are no updates for SQL Server found online because we just downloaded it. Click Next. We, for a moment. It's scanning for stuff. Stones. So I'm going to press pause for a moment so we don't have to wait for this. Alright, now the setup is complete. For this part. Took, and it took a couple of extra minutes, SY, kinda skip there. Now we click next. After that successfully completes, I accept the license terms. Click mixed. Now, you don't have to do this, but I usually installed to span everything just in case I ever need. So you can just click Select All you prefer to eat contains your instance root directory. I always keep that the same. Man. For instance, you can do a default instance or you can name it, or you can do a named instance. Protocol are named instance SQL Express while he goes Michelin name. So quick. But you can call it whatever you want. On this one, I would just do the default API selected poly base enabled in students. Time dot actually completely share when it does so, I just usually do the default and stuff like that. Install open JRE, it's asking P10 installed java. For some of the other things you install much. I'll just go ahead and do that. Sql Server browser. We want to assess probably everything to automatic for this startup type over here. I wouldn't check this box. Probably next. Okay, so usually I do mixed-mode instead of just Windows authentication mode so that I can enter my you better commander, the username, essay, and a password. Or I could just log in as admin on my boss or my computer. With Windows authentication mode, this does both. So I will add the current user, which I've already added as an SQL Server administrator. This is my user. Click, click mixed. Ok except pads going to start installing. I'm going to pause again so that you don't have to wait for weight marks. This Install, which will take quite awhile. Back. Now that that's done installing. Scroll down the slowest, make sure everything some seated outlay did. My case. We're going to click close now. Then we're gonna bring backup, the SQL Server installation center again, because there's one more thing that I suggest that when you install, it's called SQL server management tools. So click on that. It brings you to this web page. Apparently. Just click on Download SQL Server Management Studio. Okay. That'll download. Take a minute, pause until that's done. After that's done downloading, click on install, glued up. We're just going to click Install when it opens up. And does mu2 load packages for millions of students that I'll pause the video after it's done. After out. Now that it's done. Installing quiet to-dos quote close, and that's it for this tutorial. Thank you for watching. 13. SqlServer Basics: Hello and welcome to the next segment of our course on different topics and C-Sharp. I am going to spend this course talking a little bit about databases in case you have no exposure or just need a refresher on databases for SQL Server, more particularly, which is Microsoft's version of SQL Server. Most people call it SQL server. I'm just gonna give you a very rough overview of how to use SQL. Or in the most basic sense. There are a lot of courses out there that are much more detailed than this. This is just giving you a refresher background so that you can do the next parts of the course. So without further ado, let's start talking about how to use SQL Server. So first of all, let me open SQL Server. You will have a screen that pops up like this. And they'll have the option to select this authentication type, which if you select Windows, Windows authentication, and it'll bring up your Windows authentication user type. But for now we're going to login is SQL Server authentication as essay, essays system administrators. So if you install SQL, what while the base password you installed SQL Server with has the will always have the base logging of essay unless you remove it or something. I don't know if you can do that, but it's possible, I suppose, don't remove it though it's not a good idea. Anyways. So then you click connect after you type in your username and password and get the IP address, instance name of your server name. Then you click Connect. You'll notice that in our current configuration, there's not a whole lot there. And that is because I haven't done anything yet. This is a fresh, fresh install. So now, quickly, just to recap on what a databases. Databases are. A place where you saw a piece of software that you can go to store data. Hence named databases. And the most basic sense, it stores different field types, like we've talked about, the variable type, string, integer, float, decimal, double. In SQL Server has its own different types of fields you can add, and how you define how your table, your databases tables are stored and what the column names are and stuff like that will tell you, will define how you store in how you store it. So let's create a new database here, k. And we will call this database the count, an account database. So I'll just name and account for now. Click OK. You see created, created a database here. But there are no tables yet. No tables that we can use to represent anything about our account database yet. So let's see. So for the account database we may want something like, well, first of all, there's the concept of tables. And as he create tables, you have to create a table before you can put data any, anywhere in the database. So first you have to create the database and then you create the table. So right-click on tables, do new table. We'll call this table. Let's see. So these are the column name definitions in the datatypes and stuff like that. So let's see. The first table we're going to make. We'll represent user, user information. So firstly, might want an ID that will be so good types for ID or unique identifier, which is a Google ID, which is 11 way they store it. Another way to start is just with an integer, a large integer, normal integer. I tend to prefer to use the unique identifiers for my IDs because there they're pretty much mostly guaranteed to be unique. So you don't want to allow nulls for that. So check that for the moment. We will right-click this filled. And we'll set this felt as the primary key. And what that means is when you set it as the primary key, it sets this film as the primary identifier for. This table. So if you need to access this table through other table, other tables which we'll get into in a minute here. Then you can you, you, you will usually use it with what's called a foreign key, which I'll explain in a moment. So for this table, since it's, since it has to do with user_data, will create an ID that's unique identifier. It does not allow nulls because null is like an empty value. We don't want any of our DID null so that we can't screw or database. And then we might create like a user name. And then for first things like usernames where you're using strings and different things. A lot of people use VAR chars. There, there are some different types you can use. There are, as you can see, there are different types of chart. There's char, theirs and var char. There's var char. There's also, you can also start things as binary, but I prefer to be able to read the data. So very char is a pretty good option for that. So then what you put in the parentheses here is the size of the maximum size of whatever data you can put it in here. So here we have a string with 50 characters. I don't think we'll ever have. Hopefully we won't have usernames more than 50 characters long. It's possible, so maybe we should just make it a 100. Doesn't hurt to have extra space on a filled too much like that. But it can't hurt to have too little space because it's hard to it's hard to add more. But if you have too much, then it's better than too little. Because when you're inputting data, when you only have a maximum size of 50. But if you have, but if you're very chair size is eight, then you'll never be able to store that without recreating the table basically. But if you have over, over the amount of characters that you need, like a 100 and all you need is a maximum of 50. Then if, if suddenly you need a maximum of 55, you already have a 100, so you don't need to resize it or redo the table or anything. There are ways to update the datatypes, but it's not recommended. And a lot of times it wouldn't work very well when you do that. So just keep that in mind. We don't want our usernames to have empty values either. And we are going to store a password hash that is also of our char. And we'll make this 1200 just for the heck of it. And we'll also store assault. Now the concept of salt I will introduce when we're programming for this table. In the C-sharp sided with the code. But for right now we're just talking about the database. Usually what'll happen though, just to give you a brief synopsis, you'll have your password hash and then you append the salt. And then you hash that so that the, the password plus the salt hash becomes your password hash, I believe. Well, we'll get into that more later though. So so he created a username and password hash Miss salts. So we've got maybe everything we need to create. A basic user table. Though. Let's create one more field though. Just for the heck of it. We'll insert a column and we'll put email, urge her 100. We'll do 200 on this on just for the heck of it. And salt still very turned 100. So now, now we save the table. And it asks us what we want the table to be named. So I am going to call this user user. We'll just call it user, table. User. Yeah, just user for now. So now if we refresh the tables, you'll see we have a DIYbio dot user table with the columns ID as the primary key username with var term 100 email with merge her 200 password hash with a very Chair of 200 and you saw with the voucher warm, hungered. Now, one thing to keep in mind is that each table there, there are different ways to structure your table sets. And some people like to put very little, very few amount of fields in their tables. And some people like to put a lot of films in their tables, like maybe more than 20 or 30. Neither one is necessarily wrong. But one thing I have found is that if you make the tables too small, a definitely increases the complexity of the programming of your application. So try to get the child to have a happy medium, at the very least. How small each table is and how concise each thing is that needs to be represented by your tables. So let's create one more table. Okay? And this will be, i could probably be better stored in a different area of a, we're going to call this user info. So this'll, we're going to call UserInfo. So basically what we're going to have is we're going to have an ID with the unique identifier. Again, don't allow nulls k. And one thing I would like this table to have is a username. Will make that No.2 username, just a first name is what I'm going to say. It will make that a var char 50. We could allow nulls on that if we weren't too. So I'll allow nulls because some people have partial information and stuff that they stuff that they don't want to necessarily fill and every single time, right? So we'll make creative middle name a first name, and last name. Now here is where what I was just talking about comes in handy. Where your tables could be too small or they can be too big. We could stop right here and just create an ID, first name, middle name, and a last name. And then have another table that links this table to the other table for address and stuff like that. In our case though, I suggest if we're going to have user information in this table, let's put the address as well. So this is where you get into. This is where you start thinking about like what exactly you want your data structure. It will look like how complex it should be. Really to understand what you should be placing here. You won't understand it until you get into the programming aspect of it, to be honest. But we're gonna do our is this way. So address first will have address line one, char that D. Well, let's do 200 and address like one. Who knows how long Madras could be? Address line two or 200. Then we're gonna have city, var, char. Let's do 50. State or region in case where in a different country, 50 K. And we're going to create postal code or char 50 as well. You might be asking, why am I, why am I having so much space for stuff like postal code or state or region, and those are going to be pretty small, right? Well, it's all a matter of opinion. But I'd prefer to have more than less in each table and in each column name. So just my personal preference. Outer their hand Morse take up more space than needed later for any arteries. And so that's my preference in this case. So we got an address. I wouldn't address line two, city stay postal code. What else might we need for contact info? We'll call this the contact info table one. So we'll have a phone. Let's see a work or what's du? O. K var char 50. Work phone, var char 50. Cell phone, or char 50. And now we've probably got enough, enough, enough filled to represent some contact info. So we'll save this. We will call the table contact info. I was given a call user info, but I think contact impose better. In this case. It's now we've got these two tables. And how do we link the two together? So you'll see if we refresh now we have DIYbio and our contact info and DIYbio dot user. So let's create another table that's, that's a table that will link the two together. So, so basically what we will have an idea again, there'll be unique identifier, don't allow goals. And then we'll have a contact info ID, which is a unique identifier. Which lets not forget to set our primary keys. Oh, let's see. I forgot to set the primary key on this one too, so let's save that. And primary key is a primary key. And this is what will be called what is called a foreign key. So let's go to this Relationships tab. Now. Let's see. So we add a relationship K. And basically what we're trying to do is link the contact info to the user table so that we can see what user has what contact info. So basically will create this foreign key, k. And the foreign key. The primary key table for the first table will be contact info and ID. This will lead to the contact info ID. So this is basically putting a constraint on the database. And it's saying that when you add a foreign key object, it has to be, it has to be a member of this table. And it leads to this, this value in this table. So we haven't created our table yet, so it says Table one for now. Let's cancel this for the, for the moment. We'll come back to this in a minute. Let's create all of our fields also, the other filled when you use a user ID which has a unique identifier, don't allow nulls. So what we do is we save the table as user underscore contact info. So this is linking user to contact info. So back to the relationships, town. Let's delete our initial relationship so it'll put in the names we just gave it so that it looks a little more clean than we click on this general tab we could tables and columns specification. Okay. Now we want the we want the contact info 6e to the contact info ID to be the contact info ideas on the table or just creating that way. When we query into this table, we will get a contact ID that we can contact info. And then let's create an, let's close that and created another foreign key on this one. And so that the user id will have to link to a user ID. Id in the User table. Hope that kinda makes sense or is a good refresher for people that already know databases. Where you can go into databases for days, weeks, years. There's a lot of stuff to go over, some kind of going through this pretty fast. So if, if, if, if you need more info, there's a lot of other courses to supplement this. This is just a real brief overview, like I said. So, so this user, let's see, we want the user ID to link to the user ID that we just created. And we'll see how to use that now. We've got our tables. It asks if we would like, I'd click Save. So it asked if we would like to save the changes to the database, I'll say yes. So now the contact info ID on this table. Well, let's look at it in a different format actually. So now we have the user info, User table, the contact info table, and the user contact info table. So basically it goes that the reason why we created this third table. So that when we, when we get a user, we can query into here with the user ID and get basically the we can query on a, on a user ID and the contacting vote and get the contact info. Let's see. And get the contact info ID. So that kinda makes sense. So what we're gonna do now enough about creating tables, let's, let's show how to add data to tables using the interface that SQL Server gives you. It's really easy. So we go edit Top 200 rows k. Well let's see. There used to be a good uid button, but Let's, let's just leave that blank for now. So we'll just we'll just leave them blank for now, but we'll, we'll say user firstname Josh, and see our Mc. Live dress lie 1-2-3, easy street, address, line two, Aleve is no City. Is. Herman, Utah for 45. And we're now going to play sort of cell phone or anything like that. Okay, so when we try to commit this, it says, No. No row was committed because we cannot insert null into the ID table. Okay? So I'm going to do is go to website and get a random forests so we can continue on. There we go. Founded good generator line and there we have it. So now when we hit Enter, it saves. This is what it looks like. By the way, it's kind of cryptic string, if that makes sense. So it's just a long, long ID string that you can use for a lot of different things to identify. Usually it's best uses and identifier or something, or sometimes even or hash, but actually maybe, well, an identifier of some sort, let's just put it that way. So we've got our first table. Okay, good. So we got our contact info, those CREATE_USER. And what's great, let's get another, do it for this other table. Just a random good. And will have my username be miss, Mr. S. And my email. Let's make it all lowercase. And this case email will be Mr. S, MR. SOS, and the password hash. Now this is where it will get tricky. I'm just gonna put the letter a for the password hash and solve for now. Because we can only really do that programatically to actually have it do something. And I'll do, I'll show you how to, how to populate that in a later course. So now we've got ID, okay, for the user. So if we go into the user contact info page, we click at it. This is the user ID. This is the contact info. And that will be right here, this ID that we created for the contact info. Let's grab a new ID. Four. The ID for this. And then now we've popular, we've created a couple of tables we populated on with some really basic dummy data. Now what we wanna do is let's, let's try and query for the data in our so to actually view the data which is called the query. The data, we will hit new query up here. Make sure our count databases slot did in this drop-down. Otherwise, it'll try to query one of the other databases by default, and we're not going to get our data that way. So basics of querying the database. So there's, so you always have for retrieving data, there's always a slot statement, okay? And you want to do select, star is all filled. Or you could do something like ID contact info, ID, user id from user underscored contact info k. Now what this is gonna do is gonna get us everything in that table or a narrow weeks. These are the three ID's though we populated, it's all working fine. And then if we wanted to get this one specifically and only that one, we would do where id equals and see how it gives the same thing because there's only one row. With this information. It's the only row we have. So that's why it's the same thing. We could also put instead of select ID, contact info on user ID, we can put thoughts star and select star will give you all the table films. Now, let's select. Let's do a join. So let's select from user. I will give it a neighbor view. Come enter. No, let's just do comma comma contact info, CI. And we'll select u dot star comma ci dots, Dar. Kay. Let's see. Maybe it's users. So DIYbio dot slug, or a moment here. Let's just do star in general. Okay, so this is one moment. Yup. So sometimes when the database has keywords like users, something like that, sometimes we'll want you to do is put square brackets around the table name. So that gets rid of that compilation error K. And we're going to do, we're going to join three tables on this one from DIYbio dot user, DIYbio dot contact info. And we'll call that CI per contact info you for user and DIYbio dot user underscore contact info for we'll call that UCI. And we're going to do where tidy equals that k. And what we want to output as a combination. We don't want our PUT everything necessarily. Uci. Kay, so if require this right now is gonna give us everything from both tables, from all three tables actually. So in this case, we might wanna do that or we might want to just narrowed down sale we want is the username, the firstName, lastName, K. Though we run that all it's going to return is the username, first name, and last name, because that's what we specified up here. Basically, when you do a select u, this is the route. Now let's go round about back to the beginning. So when you do a select statement, you want to do select the field names you need from the table. The table names you need, and you can give them an alias or a name, like a variable name and programming. These are the variable names I gave these three different tables and then are the alias names rather. And then you put where. And you can also order order by like firstname for instance. So you can go descending or ascending. And it will, well, in this case we only have 111 filled, but r 11 row in the database. So, but sometimes there will be hundreds or thousands or millions or billions, et cetera, et cetera, of rows in the database. So how you structure your queries can sometimes even make the database stop working if it's a big enough query. See you want to be careful on bigger datasets. Practice on small datasets first. So just to recap what we went over in this very, very, very quick lesson. In a very basic sense, what tables, how to create tables, how to insert into a table using SQL Server. And the how to select the data and how to, how to. Let me show you one last thing. So there's this nifty thing to, if you just want to select one table, you can go right-click on the table you want. Go select top 100 rows. See you right-click on the table, select top of 1000 rows and it comes up with something like this, where to list every Phil. And it'll be explicitly, it will explicitly put every name of every filled in your table. So that's it for this lesson. Let's see. Hope it was helpful to a lot of people. It's not supposed to be by any means comprehensive. And it is. This lesson is really just a quick introduction. So I hope that you learned a little bit of something in this segment. Thanks for watching.