C# Programming: Your Beginner Guide to Basic C# Code | Matthew Dewey | Skillshare

C# Programming: Your Beginner Guide to Basic C# Code

Matthew Dewey, Writer, Writing Tutor

C# Programming: Your Beginner Guide to Basic C# Code

Matthew Dewey, Writer, Writing Tutor

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
16 Lessons (1h 56m)
    • 1. Introduction to C# Programming

    • 2. Course Overview

    • 3. Course Support

    • 4. C# and .NET

    • 5. Application Structure

    • 6. Installing Visual Studio

    • 7. Your First Line Of Code

    • 8. Data Types, Variables and Constants

    • 9. Overflowing and Scope

    • 10. Converting Data Types

    • 11. If Statements and Operators

    • 12. Nested If Statements and Additional Operators

    • 13. While and For Loops

    • 14. Retrieving User Input

    • 15. Project 1 Discussion and Answer

    • 16. Conclusion to C# Programming: Your Beginner Guide to Basic C# Code

  • --
  • 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.





About This Class

Welcome to Your Basic C# Course for Beginners 2020!

My name is Matthew Dewey. I am an experienced programmer, having received several accommodations on programming in my formal education as well as tough several programming languages to thousands of students. My goal is to provide you, the budding programmer, the knowledge you need on programming in an easy and fun manner. In this course, I do just that and with one of the most useful IDEs coupled with the C# programming language.


C#, a wonderfully simple programming language that has encouraged many programmers to pursue careers involving C# over any other language. Of course, it goes without saying that C# is an excellent language, but do you know what is required of you to start programming C#?

As with any programming language it is important you understand the fundamentals and that is exactly what I teach you in this course.

You will learn how to:

  • Install your IDE

  • Establish fundamental code

  • Create and use variables

  • Retrieve user input

  • Process simple data

  • as well as BONUS methods and code!

What about Visual Studio? A popular, widely used IDE that many large applications have been created over the years. Do you know how to use it to its full potential? Well, in this course we will go through several lessons that will help you get comfortable with the IDE as well as more adept at program creation.

Go no further if you're looking for the course that will guide you into the world of programming! With my course, I can guarantee that the knowledge you learn will help you get a head-start in C# programming. I hope you enjoy the course and it helps you on your way into the world of programming!

"Programming is a form of art. It is logical creativity!"

Meet Your Teacher

Teacher Profile Image

Matthew Dewey

Writer, Writing Tutor


I have been writing and teaching for years, helping tens-of-thousands of students achieve their goals, be it completing their novel or publishing their work. Having written several novels, non-fiction books, hundreds of short stories and articles, I have studied and put into practice the best methods for writing effectively and efficiently.

In addition to writing, I am also a programmer and artist, teaching what I know on the subject and helping those interested get a headstart.

If you want to write a novel, a story that has been on your mind and not on paper for too long, my courses will not only help you start, but I will be there as well. Any work you submit, I will happily read, review. If you need professional advice or a friendly opinion, I will be there for both.See full profile

Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
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.



1. Introduction to C# Programming: hello and welcome to a C sharp course. My name is Matthew doing. I've been programming for eight years and teaching for four the years now 2020 and the world is now filled with many ideas and projects or involving a C shop programming. First, let us talk a little bit about C Sharp programming. Now See Shop Program is one of the most popular programming languages used today up and used for applications, absolute phones as well as video games. Now, with developers constantly working on such massive projects, the programming language is not only popular but has a men's support as well as a watery off capabilities. In this course, we're gonna be using one of the most popular see shop programming I D. Ease, and that is Microsoft Visual Studio. Microsoft Visual Studio is the Audi that I'll be using throughout this course, but it is not only one out. The if you're using another is such as Iris or Lennox. I recommend you dollars any of the sea shot bodies that would work for your ways. But don't worry, the programming doesn't change. What you learn in this course can be used in any I D on any OS. Now you have decided to learn C sharp programming. 40 of a reason you've decided to learn the programming language. I know that in this course I'll be teaching you the foundation off. See shock, giving you a better idea of how to use your C sharp programming skills. Hard to develop your problem solving skills in order to make you a better programmer. And these are skills that are incredibly important because you can know a lines of code possible with C shop. But if you don't have the problem solving skills to create applications as well as debugging, then you can have a tough Tom as a C sharp program. But that is something you don't have to worry about as I'll be guiding you through several projects along the way. Finally, our try to make this course entertaining as well as insightful. There will be a structure with the course, but I try and keep. It also is and former as possible in order to make sure that you and I are both relaxed in order to make our programming. But easier to further this effect. A large part of this course will be practical, giving you the opportunity to follow along and test your growing programming skills. Now, to start this course off with, I'll be giving you some theory lessons, for example, explaining some jargon that you best know when working with C shop. After that, I'll help you into your first beginning stages of being a programmer. Really learn your first line of curd and then eventually create your first program. Now this will be followed by many sections, which will help further your skills teaching more advanced, see shop code along the way. In the final section of this course, you'll be working with complex lands of code grating interfaces for applications. Now it's just a short step from there to creating your own products to sell. If you're interested in Apple, even video game development. Now, without further ado, let's take a step forward. Thank you for watching, and I'll see you in the next video 2. Course Overview: Hello and welcome to your first video. In this video, we're gonna be doing the course overview so you can get a good idea of what I'll be teaching in this course. Now, this is a course that has been split up into several sections, which will be released periodically. If you have joined me in the beginning, I'll be discussing First of all, the beginner section of this course. Each part of the course will be explained as I will have an introduction video at the start of every section. It is also recommended that you start at the beginning of the course and followed from the However, if you feel that your striking with a certain section is based to start the and watch from the onwards as it'll keep with the flow and structure of the entire course, is that we can keep up to date with what we're learning now if you vote so join me in the beginning stages off this course. When I first publish it, you only have the beginning section, or perhaps only a few sections after instead of the entire course. So I recommend you follow my profile so that where you're updated with each release. It is this way that you want. Miss out on anything and you'll make the most of this course. Now the beginner section. After this video, I'll be doing three theory videos discussing some jargon and important facts about See Shop that you do need to know now. These are simple jargon that will need to know from the very beginning they'll no doubt b'more that you learn along the way. But before we start, these are really the important terms that you'll need to know after the Serie Videos will then download and install the I. D. Microsoft visual studio, and then we have strayed into our practical work. Now the beginning section will start with you with your first line of curd and then end with you, creating a project which will retrieve using input. Take that Dr process it and are put it as information a fairly basic project, as you'll soon find later in the course. If you feel you really have a good understanding of the section and I recommend you go to a later section. However, if you still feel this some parts that need to be covered you can pick and choose which videos are best suited for you. Which ones you would like to go over mawr, perhaps study from a different angle. Now I won't go too in depth when explaining the sections that come after. As there will be an introduction video to each section, which will do just that, However, I can go over some major points on what will be learning throughout. This course will be working with classes, objects and er p, otherwise known as object oriented programming. Cross coupling, inheritance, abstract and sealed classes, interfaces, asynchronous programming, just to name a few. But these are the major points that will be working with throughout this course. Of course. Don't worry if you don't understand what any of this means right now, when you get to this section, you'll have a hands on approach, which is the best way to learn programming so you can experiment and practice of the code that you learn as I teach it. By the end of each section, you have a fantastic understanding off all that I have talked about, and with that, this overview has come to an end. In the next video, we'll be going over core support. I will be discussing with you how you can communicate with other students joining me in this course whenever you hitter did in. You can always ask for help and which services you can use as well. And with that that concludes the video. I'll see you in the next one. 3. Course Support: Hello and welcome to your core support video. Now, I would be hasty if I moved on with the course without creating this video. Nevertheless, I try to keep it a shortest possible now. With that in mind, it is not too crazy over thought to think that the maybe is part of the course that you struggle with. I have taught thousands of students in my career, and students generally hit a point where they learning too fast. They start off any course with a measure of confidence where they think OK, this isn't so bad. I'm understanding and I'm working well, which is great, but it is common enough. We're student will hit a point where they are learning tumor. It's at this point that you're gonna need to start asking questions. Gun of the days are being shy in school, too afraid to raise your hand and ask such questions. I am a four time instructor and try to answer as many questions as I can. But luckily, I also have many students watching my courses as well to help answer any questions that you might have along the way. With that in mind, you need not only be the one asking the questions. If you see a question in the discussions below that you can answer, feel free to answer them. I read these answers as well and mark the best one so that we could have seen directly below the question. So if you have a question that you feel like asking, you may find someone has already asked it and an answer being provided. So be sure to look at the discussions below. If you are confused. If you take full advantage of the discussions below, it will make your workload easier, as well as other students who are struggling A swell. A community of programmers are watching these videos, and being a part of it will only benefit you as well. However, if using the discussions to your benefit isn't much to your learning style, there is a service which you could make you soft to help you. If all your programming needs now such over to my computer so I could show you how to make use of it as well right now that we're on the computer, you could see I've opened my search browser, so that way we can go to a website called Stack Overflow Stack Overflow. RZA whips out discussion service, where many programmers seem to collect when they start studying programming. Stack overflow contains many answers to any questions that you have, so it's that ammand it is a wonderful service to make you so if you are having a problem, chances are thousands to tens of thousands have had the same problem and have gods and walk throughs explaining each step you can take to solve your problem in stack overflow. Simply Google being or searcher problem, followed by stack overflow and the language you're using, and you have links to pages with the answers. So if our top retreat in using import in C shop with Stack overflow off to its and press enter, a page will come up how to ask for use a plea input, for example, and they will be answers to the question below. Normally, these answers will contain great examples for you to work with and use in your program. Now, is that a mind that concludes this course support video, and I hope you bear this programming support in mind. I'll see you in the next lecture 4. C# and .NET: Hello and welcome to another video in your C shop programming course. Before we can get into the practical side of programming, let us establish some fundamental jargon words. You're here often in the program in Korea, but more specific to you. As a C shop user. First, see, shop itself is a programming language. It is among the many programming languages that dominate the world today, from path onto Java to the rapidly growing swift. Secondly, if you have been thinking about becoming a seashore programmer, you might have read or heard the term dot net dot net framework dot net is a framer used to create programs and applications will be using it for our programming, and you'll learn more about it as we go. But know that the doctor made framework is not limited to only see shop. Other programming languages make use off dot net. But of course, that's not something to worry about in this course. Another point to understanding the world of programming is that the Kobe Rot is not part a computer reads we as programmers are creating a set of instructions for our computers. Yet there being many different computers in the SRT translation between them is messy. At least it used to be in days long since passed, a programming language was translated immediately into machine code or native code, which is the language that our computers understand. Yet when you take this code to a different make of computer is the code doesn't work today . It is a problem now solved with I L code intermediate Language code. Now our set of instructions written in whichever programming language is translated into this I l code using our computer compiler, which is then translated once more into the machine or native code using seal our common language runtime. Thus, although I am using a Windows computer in a Windows I e, you might be using IOS or Lennox, you can stolen C sharp. You might have to use different software, but you'll be able to create the same results with what you're working with. If you're going to be working with a team of programmers, it helps to know this if a problem should arise with your code being improperly translated , although this is unlikely if you're gonna be working in a large business, jargon like this is useful in confusing your superiors and securing more time for your project now, was that being said that concludes this basic jargon video in the next video? We'll be discussing a bit more on the dot Nate architecture. Thank you for watching, and I'll see you in the next lecture. 5. Application Structure: Hello and welcome to the last theory video before we install visual studio before we get straight into the programming I need to establish for you how an application is structured on application isn't one program. At least it isn't. One program in the program is months. It an application is several programs working together to upload information or complete a task. When we are creating more advance programs in the future, you'll be creating each smaller program toe work with one another. The's small programs are called classes. Classes can receive and contain Datta, or they can contain methods. Daughter being the raw information provided by the user, methods being the instructions and processes that are run when surgeon information is given to explain it simply, let's take the scenario off making food. The doctor that has provided is as follows. First you're hungry. That is what starts the application. Second, you have certain recipes in mind. Third, you only have search and ingredients for certain recipes before that information. Given there are several methods that need to you run before you have a meal, such as a method to rule out any recipes. You can make any recipes you don't have the ingredients full. Amazing, which calculates what you've had recently a method that gives your body instructions to make such a meal and so on. Now that is what is important for you. To understand this lecture, you need to understand what a classes, what daughter is and what methods are. As we practiced in this course, I will show you how to organize all this into certain groups, such as classes within name spaces, name, spaces within assemblies and assemblies within applications. However, the terms classes, daughter and methods are what is most important. As long as you understand what these mean. You should have no problem continuing with this course. And with that amount that concludes this short Siri video in the next video, we'll be installing that I e visual studio and begin programming. I'll see you 6. Installing Visual Studio: hello and welcome to see Sharp begin. Of course, in this listen, we're gonna be downloading and installing the software visual studio if you already have the software installed, and please feel free to skip to the next lesson. However, if you're unsure what buttons and options to press, please continue watching. The first step in the most obvious is to open up your browser. I'm going to be using Google Chrome, but you can use Internet Explorer, Firefox or whatever works for you. Once you do this, go into a certain browser and Google or search visual studio. Once you have done that, he should be presented of the following results go towards the top tap. You should see a visual studio dot Microsoft dot com, and you can click your or You can go straight to downloads begin. Once here, they you can choose one of the three options that you'll have here Visual Studio 2019. You'll have the community option, which is the free open source version, which will I'll be using throughout this course as a caters to all students. However, if you wish, you can get the professional enterprise version, so you click on free download here. Now you're download will begin in a moment, and you should see a dollar bottom of the screen here. Once you have that, you'll be going to your downloads folder and we can begin the installation. So here we are, the desktop I already have downloaded the DXY, the installer, the community issue are now begin to install at us. Asked me for administrative pledges and, of course, our click. Yes, you'll be presented in this box. You click continue after waiting. You should then be presented with following. It is here that you're going to select. You don't need framework. As we discussed in a previous listen. The dotnet framework is what we used to create our applications. Now, if you don't your desktop and mobile on the workloads tab, you should see dot need desktop development and hear your click and select and then install . The process might take a while, but I will see you in just a moment when mine is complete. Once your installation is complete, you'll be presented with a son in page. Now you can choose to create an account here now or later. I recommend that you do. I want to do that, you little son in as I will do now, Once you have logged in you, then choose the top of style that you only use now for visual studio. You commonly use a more dark theme. It is often the style that is used with visual studio. But I always would be using it in this case because the darker theme is not only better for the ARS and you is a viewer will no doubt lacked a lot better. So I'm gonna be using it so you can watch videos for a longer period of time. It also helps programmer who spends a lot of times a desk. So with that amount, stop visual studio. Now it does take a moment to start up in the beginning stages, but it does get Fastow each time, and then finally you'll be presented USCIS. You can create in your project open. All projects will continue without code. Now you can create in your project. You continue without occurred, whichever you use. It's fun. Now I recommend you choose to continue without code, as I will be giving you a cool software tour as well as creating a new and first application in the next video. And I love story in the software itself I'm gonna in the video here in the next video will be going through the soft ways different features as well as creating our first application without first few lines of code. Thank you for watching, and I'll see it in. 7. Your First Line Of Code: hello! Program is and welcome to first listen into some practical programming with C shop. Now, as we have now finished installing our software visual studio were already to begin Koerting. Of course, Now they are some pure smaller steps to take before we can even begin topping out our first line of coat. The first thing that we need to address is how to create a project. No matter what I d you use, you'll have to create a project which will contain or your code or some really generated code that the software already generates for you. The first step is to create a project no matter which I d. You use otherwise known as integrated development environment such as visual studio, you will have to create a project which contain all your code. Now, visual studio will sort out some basic files and code for you. Ready? It does this with bodies as well. But these simple lines of curd are really just background Kurd that we don't really address , but it's still very necessary if you want to make full use of the program itself. However, your code will still work without them. But we're gonna be focusing on right now is the code that you will be learning at the very beginning with simple output. Land. Now, to create a project is simply go to file in the top corner, Got a new and click on project. Once you're here, you're presented with the variety of options. Now, recently, visual studio has gone through several updates to uneaten up. This process for program is going on so used to the software itself at me. I found it, but confusing at first. And if you're familiar of C sharp and getting back into it with this course, you may see something a bit different here as well. It don't fridge. This is simply an organization tool used for visual studio. So you confined your deal project? No. You'll be selecting a language at the top. Obviously you have a variety to choose from. Were working of C shop. You can choose platforms. Now we're gonna be working with desktop. I'm gonna be with Windows. And as for project tops, we're gonna be working with a council application. We'll finally narrow these down to two options, and I'm gonna be using a top option council app dot net Cool Now don't Nicole. As you can, meet your description, but allow me to explain it further is simply put, a command line application that allows us to run on several different oases. Now this is a larger ones. As you see here, Windows, Linux and Mac are so Eilis, or you can use the duck framework, which works with Windows. However, I'm gonna be using this one just in case you are using a different oasis. So I select it and click next. We now get to choose way our project stored and what to name it. Now, traditionally, your project names. When it comes to the naming conventions, it depends on the different languages you use. Some language conventions allow names such as Let's Say, First Under School project a simple name separated with an underscore. Instead of the space, you'll find this quite common reworking of programming that fairly often you won't be using a space, as this does jeopardize some code. Now another naming convention is without under schools and simply put first project capitalizing the first letters of each word. This is a naming method that's often used by Java programmers and was the first name in method that I came to use. And, of course, you could go lower case first and then capital. From then on project to separate the different words you could choose which, ever one you feel most comfortable with. This is simply naming the project. As long as your code keeps to the naming conventions, you'll be just fine. So I'm gonna stick with my Richa and stick with capitalizing the first letters of each word . So that's first project. How leave the location as the default frankly create. Now we're presented with several bars and boxes, as well as 13 lines of code, and I'm going to go through each with you quickly. I start here on the right of the software as these other boxes that you won't really be focusing on until you working with more advanced projects. When you start creating something called classes, which I'll explain further as we go along, you'll see them or hear organized for you to have easy access to, and it'll of course, list the different types of programs that these classes contain and was in each class. It will contain a set of methods that you'll be creating in future again. I'll explain that in a moment, of course, this is purely who organizing your classes and methods, having quick access to them, deleting or adding waiver necessary. Of course, as I said, we won't be using them for the beginning listens, so you don't need to worry about it right now. And of course, the properties will be the properties that affect these methods and classes. But of course, with the console application, we don't really have to worry about that either. With that being said, I do want you to notice will be working with them when we get to more advanced features off C sharp programming and visual studio. However, for the beginning stages, I want you to put it at the back of your mind, as you don't need to worry about the metal. This is where we will be writing our code. Most of this is pre generated. If you're working from scratch, I do recommend you write what you see on the screen now, and that is a Letter Felitta character for character. Make sure that you have the right letters capitalized and so on. However, if you have followed the steps so far correctly, All this code will be generated for you now. So let us begin with explaining the first line of code. The first line occurred. Using system is something we call an import line. Whenever we want to use specific methods, we call upon a project and we included here. Now, this is pre generated code and system contains good that we might use in a consul application. Right now you will notice that the line itself is fairly darkened because right now we are not using it. If I have a overt you should see here, using directive is unnecessary. We have yet to make use of any methods that system contains. Now, in future, you learn how to import your own programs. And, of course, any programs that anyone else is created and is providing for you to use. Finally, I want you to note that at the end of the line of this code is a semi colon. Most lines of code you'll be working with end with a semi colon. Of course, there gonna be some exceptions, but not really. It simply comes down to organizing it. Most lines of code all of course being with the same column. And if we were to look into systems project, it would look like this. It would have name space system. In our case, we have name space whose project and all that is contained within the project gets encapsulated in these curled brackets of the year. Notice an opening one year and a closer one. Yeah, Visual studio lands them up with started land, so you can better see how it all fits together. Contained within this project, we have a class this cost. His name is program, that is the main program was in the project and once more or that is contained within, is set out with these two brackets. Contained within the class is what is known as he mated. In this case, it is the main method, a method that is executed when the program is run more on that later. For now, what we need a focus on is what the May said contains we are gonna place are excusable code within this method, meaning that when we run the program that will open up the project, open up the cost program and then open up the main method running all the code contained within when it comes to different methods will be creating a future. There'll be some changes to the name, of course, as we don't want to clash with this program by calling another method main and using the same lines of code. Another important thing to remember, especially when it comes to naming conventions now that we have covered the code that is presented to us and pre generated were really to rot our first line of code. Now, if you're an experienced programmer, worked if another language before you know that the first line of code as by tradition is an output line of code that simply outputs the text. Hello world. The reason this has become a tradition is it is the most simple line of code to learn. And since most programs are gonna be working with output, it is simply correlating with the desire that a program has so first, let us begin with that code to create an output and see shop. You're at the following council, right, like the city of normal brackets and closed with a semi colon. Now Consul is referring to the council, which will be out of putting the lan right, lan is the method that is called upon notice as we call upon dot Right, lan, using system is now highlighted back into full color instead of dark. And that is because we are now using code that is coming from system. You're not just as we progress, Further analysis since that a method often is presented this way with a period and then the name of the method. Following this method, we have a set of brackets. The reason being is that within these brackets, we're gonna place the text that we're gonna be out putting the method cause for us to provide a text that it needs to output. So, of course, we include these brackets. And as I mentioned earlier, we end most lines of code with a semi colon. This relates to the soft. We know that this clan of code is done. It needs to be executed before it moves on to the next line of code. So now let us place text within these brackets to place text within the brackets. You need to understand that they are two different types of texts you're gonna be working with single quotation mark texts which contain only one character. And then there are strings which will be containing an entire set of characters. So that is double quotation marks to encapsulate those and was in these double quotation marks, we simply put the text read, We want out, put it. And as I said before line of text, we have put his hello world and there you have your first line of code. It is fairly simple to start off with. You can duplicate it and create many more afterwards by putting different lines, texts and so on. So I'm gonna change this one now too, huh? You wish to Mom on a save my program? It's important to save your program, of course, as often as possible, and back it up if you're working a large projects but also to save your project before you run it. Now that we have done that, we can run our project to run your project. You can go to the top over here and you'll see first project next to a green play button clicking. This will run your project. Once your project is run, you'll notice now has opened up a consul window. Since this is a council application, it goes upon the consul under built within your system. And as you could see at the very top, this are putting our lines of text on the world. How are you? So our program so far is effective now, before we in this Listen, I'd like to go into a little bit more detail for you to experiment with. Once this video has come to an end, we have made use of the method dot Rutland, it is a second, similar method which we're gonna be using. It's gonna be called dot right. Instead of a line. What dot right does is output a line of code, but without creating a space afterwards. Now, the only way to really show this is to copy this line of code of here pasted over. Yeah, and I'm gonna change this to another line of text that say test safe run program once more . And now you can see here that the console is opened again. But now we presented with instead of three lines of text only to hello world. How you and without space. After the question mark, we have test printed This is because when you use the method dot right plan, it creates a new LON. After the line is being printed, however, dot rot does not do this. You'll find this comes in handy. We're working with certain programs and future. However, now it does create a rather logical sentence. To fix it, we would have to create a space before test or after our use question mark. We simply change the line of code to instead of rot to rocks Lon like soon Is that your basic lines of code? So I doubt you'll have much to experiment with. But of course, we'll be learning more lines of code in future. That concludes this introductory lesson on your first line of code, and I'll see you in the next lesson, where we start out for a section into seashell programming. 8. Data Types, Variables and Constants: Hello and welcome to another listen of your see shop programming course. And this. Listen, we're gonna be discussing variables and constants as well. Some doctor tops. Now let's go through what All of those mean first, Dr Tops, Dr. Tops are simply tops of daughter that can be separated by the daughter within, For example, the doctor Top string is simply a daughter top that contains a lot of text. Now this text and contain anything from letters to numbers to special characters. Another doctor Top will be working with is in Tages in Tages on numbers, and these numbers can range from some way in the range off negative. Two billion to positive to billing. But of course, they are different tops off these daughter tops, so they have different ranges. We'll be going through that in a moment. First thing we need to do is great. A container for such a daughter top. Now these containers are called variables. Variables are simply containers that were son, certain daughter top values, and we can name these containers whatever we wish. Of course, the naming conventions are will be discussing in a moment the's naming conventions being similar to the naming conventions we learned in the previous video Sonatas Great to variable with the daughter top string as follows to create a string variable simply topping string and we give it a name. Now the name of this variable doesn't have to be anything special as long as it follows the naming convention we discussed in the previous video. So let us name the variable as follows. So I'm gonna court name as it will contain a names I put in an equal son and I'll give it a value straight away. And to encapsulate this value, we use double quotations. Now this is only with string daughter tops. If we were working with a number daughter top, we don't encapsulated in anything. But of course, that always depends. So Louis encapsulate value on Let's just say the name John. And as always, we close our line of curd with a seamy column, and that is a string. Now we don't necessarily need to create a variable and give it a value straightaway. We can create a variable and use it later. So such a string just say second name and closer to see me column Now that we have great to that variable. We can use it later. The reason why we would do it as this is because by having all your variables in one place , you can see what you're using and what you are not using. If we were to give it a value, are simply topping in. Second name equals Smith close with a semi colon. You also noticed that I don't top in string a second time but happen in string. We're letting the program know that we are creating a variable that is off the string Daughter top. Once we have done this, we don't need to let the computer inner. Which name has a certain daughter top. We've already established what daughter top it is, and we don't need to do it again. If we were to do it again, it would create an era. So if you put in your string, second name equals Smith, you noticed that is now underlined and rain. This is because the variable has really being created. You don't need to create the variable again. And this is very important as this can save us from clashing with other variable tops again . So let's suppose we create this variable later in our program. And if we didn't have this warning system to tell us how the program would have work with, simply override certain daughter, and that could lead to some problems later. But now that's one daughter top to work with. It can be used simply if we go to our consul dot right line, which we learned in the previous listen. We can output this starter so far, topped in name and ran the program. You know, just that a C M D bucks will appear and it'll print the name, as you can see here. But more than that, we can add valleys together, so we've really created a second value. Now let's add that value for simple plus symbol topping second name and run the program again, you know, just for inside both values right next to each other. Now, this may seem like a problem at first because since the names are together, there's no space in between them, so there's nothing to separate the names Now. We can fix the problem by adding the space after John or space before Smith. But quite simply, we can also do this in our output line as well. So we have name plus second name. We cannot serve name plus double quotations space in between those double quotation marks, plus seconding. Now this is no different from adding the values John Space and then Smith next to each other. The computer reads name as John and second name as Smith. So if we print this out now on our CMD, it prints out John Space Smith. So the program is working correctly. Now let us work with something else. Let's go straight into another daughter top. The next daughter Top will be working with is known as the character daughter Top, which is represented with a char instead of string. And Alex is great to start atop CH equals, and now the character daughter top is a dollar top that contains only a single character. Not any more than that. And this character can be anything from a special characters such as the At Symbol Presented son or can be a little can be a number. And instead of encapsulating it in a double quotation marks like a string, we encapsulate characters in single quotation marks, so it's something like the later why closer for semi Colon and you cannot put it the same way as you do with a string. Now, while we've finished with the text based daughter tops, that's moving into some number based other types as we're gonna be using these quite a lot . Now there are several daughter tops when it comes to working with numbers there is, but which it creates a small range of numbers that we can use. I believe the maximum is 255 after but comes short, which is an extended range. Then we have end, which is short for intelligence, and then we have long, which is the longest range for the number daughter tops. Now. Commonly, we only ever use int into such a massive range. And also it isn't so massive that extraordinary amounts of data cannot be entered. So it is common enough in most programmes and sometimes the most programming languages. To use int pointed you now to create it into variable we do is the same way we great a string variable and let's give it the name numb, which is a common name. Is it short phone number and give it a very. And as I stated earlier, we don't encapsulate these values in any quotation marks. Numbers are simply put our numbers and you can have a number such as far you can have a number such a negative five. And I believe the range when it comes to introduce is some way in the negative two billion to positive two billion range. These are extraordinary numbers that we don't really need to worry about. So that's why we're gonna be using into commonly throughout this course. Now, before we move on to some other daughter tops that we're gonna be working with. You need to know that you can also use math functions with inter GIs. So we've got at council Doug Light line one small way. We can add and subtract values with the same symbols we can add and subtract values from the number. So if I take numb and I add five to it, it reads it as an inter job and we run the program. We should get a value of zero, which we do negative five plus 50 and that's only one of the math functions we use. And of course, we have a minus for the subtraction. We have an ass tricks for the multiplication, and we have a forward slash for division. Now. If we ran in this program, we should get negative one, which we do. There's a some of the math functions that will be working with, and those are the most common you'll be working with as well. Now let us move on to another form, off number daughter top. The next daughter Top will be working with contains decimal numbers, and we create variables for this daughter top as follows float, which is one of the names we use. Another is decimal, and another is doubled once more. These three contained various rangers, ranging from the shorter's to the longest being double, and commonly we use double as this is such a mess of range. To work with that again, it is also incredibly useful. However, if you're going to create a program way, having large numbers is going to create a problem. It is better to use these smaller daughter tops in order to save you those problems later on, such as Barton Short or float and Decimal. Now, when we create our double, it's also helps were naming to let the program and know that this number is a double. You can do this by topping Indy numb or F number. If it's afloat, we'll give it a value of, let's say, 10.7 and end with a semi column. Now, with those daughter tops out of the way, let's move on to a more complex started time building. Building is a daughter top. You'll find use a lot, even though not directly as a variable ruling contains only one off two values, it can contain 1/3 but that is the third Valley that any very book contained, which is a void where it doesn't contain any value at all. However, the two values it can contain if it is given a value, is true and false. Now this true and false color should be represented, with a zero and 10 being false and one being true. To create a boolean variable, you simply topping bull and you give it a name that suitable. Just give it a name. Taste for now, and we give it the value of true. So there are a 1,000,000,000 variable now has a value reason. This value can be important is when you be working with more advance lines of code. You need the go ahead for the computer to run that line of Kurt and the way you let your computer know if it should run. This land of curd is if it is true or false. Ruling your fund is an extraordinarily useful daughter top to use, especially when testing daughter. And there you have it several daughter tops that you're gonna be using throughout your see shop programming. Korea. Now these daughter tops do require some practice, especially the number daughter tops, as you will be working in a lot of math functions in future. What's all this? Daughter tops out of the way that there's one more thing we need to talk about. We've discussed variables and daughter tops, but there's one more. Constance Constance are variables that will be unchanged by your program. Now, as the name suggests, any variable that has made constant cannot be affected by the program, but only by the programmer himself or herself. So if we create a constant variable, such as follows CEO in his tea, give it a daughter Tom String, and it's just called a name whose name and give it another name, such as Mary and closed the seamy Conan. When you're working with this variable later in your program, if name, you'll find that your program will be unable to change its daughter. So it's also important infrastructure programme accordingly, as this can lead to errors later on. But the reason we created a constant variable is to make sure that the doctor does remain unchanged. If you wish to preserve daughter is preferable to make any variables containing large amounts of daughter Constance. This way you can contain the daughter and up lose it later in the program, especially if there's an era. Now we will be working of constant variables mawr frequently in advanced programs. However, in the beginning stages of R C sharp programming, we won't be working with Constance at all the beginning stage. All of this course is to help you get more familiar with certain code. And was that a man? We won't be creating such advanced or large programs where we need to make any variables constant. However, it is important to keep this in mind, as we will be working with them later. But all that said, this listen has come to an end. Opie. Do practice what you have learned in this lesson. Experiment with different daughter tops and you'll have a great understanding and be ready to be work with our next line of code in the following. Listen, Thank you for watching, and I'll see you in the next video bar for now. 9. Overflowing and Scope: Hello and welcome back to another. Listen in your C shop programming course, in this lesson, we're gonna be going over overflowing and scope. Now overflowing is when we give a variable daughter top a value that is greater than it can contain, for example, but is a number daughter top that can only contain a maximum value off 255. So if we create that now, let's say But numb equals two semicolon. There'll be no issues when we put it with the council, right? Like so. However, if we take this number and we add one to it and then I'll put it like so you'll notice it. Prints zero. What we have done here is overflowing the variable. Since body can only contain a number of to for half maximum, it cannot contain 256 sold reverts to zero now. There's no problem when this happens now, But in a program where certain values are required and you're worried about overflowing, it is better to use a larger number top, for example, if its bite you might want to use short or integer more commonly. And to be honest, it is not often that people will use bite. That, of course, depends on the program and how you want to run it. If you want to have a more efficient programming, would use bite. But of course, that is taking a chance. If that part very can be adjusted to Higher Trooper five, so that is overflowing now. This can be resolved by creating a chick code book. Now this creates an exception, which is more common of certain charities that I've worked with in the past, such as Nick Beans in the Java programming language. What this does is great. An exception, Adam can threw up an era, and of course, this will make it easier to spot. However, that is a different story. To create such a checkbook, you simply top in check. You create a sit off curled brackets like so I prefer to create in this way or properly and maintained beneath. Um, it's that way when I have ah checked on the parentheses below it, they get highlighted, but the indentation helps needing up programming what makes it easier to read and work with . But that being said, let's now work with this. We create another body here and we're going to get a value to 55 will add to this value with number two plus plus, and we'll put them to, like so, some going to remove the slump. Could here just leave this are in this and you'll notice an exception appears. This will let us know the problem. And as you could see, it highlights the problem for us, which is, I said, can be useful in some cases. But as I said earlier, overflowing is something that could be easily avoided by using a larger range in darn it up . So that is overflowing pretty simple. And it introduces something new that we're gonna be working with, which is code blocks. Now. Cut blocks are simply just parentheses containing certain code. What this does is separate certain code from another batch of code. For example, if were to create a curb block here inside the main mated, any any code contained within this parentheses will be run. But anything that is asking of it before after cankles problems. So, for example, by critics string variable, it's seeming equals. John and I create another variable. Let's say string last name equals Smith because it was seen me cut on with the land council dot Rod Land written. I'm gonna place a very bunny. Everything such as name now, name has no problem as it is contained within the same code block as you could see. Yeah, but if I tough in last name, like so you're noticed there is an era. That is because the council that rot land cannot fund string. Last name. This is because it is contained in a separate car. Park for you is a program I created. The separate her blocks is incredibly useful. In doing so, you can create smaller programs, which is much like our classes work. This also allows you the ability to create the same variables of the same names, which, of course, going to be more useful for you. However, you need to understand where your code blocks are and how they work. So the valley is now contained here will not be used. However, you notice that if I create an output line council dot right line as follows and I put name in it, it has no problem. That is because this is contained within the code block over here, meaning any code contained before this Kobach can be used anything after, though you'll find that there's also problems. So my creation of the string, let's just say strange if name equals double quotations and it's a taste now, and I put if name in the output line, you notice that there is a problem it recognizes if name is in the color block, but it's only given a value after the smaller curb block within the main cookbook. Now, this is also important to remember when you're creating larger programs, you cannot ask the program to use code that hasn't been written yet, even if it is contained within a code block that is encapsulating a smaller Kurt Bock. What is important to note is that you can use code has been used before the smaller code book. So what, then amount. It's just changed Islamic good and give it a code that it can use such his name. This is what is known as scope. This is the scope of code and way can be used. So it is important when using these code blocks to understand where your lines of code can be used and where they can not this way, you can use them effectively. And he goes, so organize your code a bit better, once more like overflowing. This is something we try to avoid. As long as we organize our code indented properly and give more descriptive names, there really isn't much need for Kurt Brooks. But of course, as it depends on the complexity off the program that you're creating, you may find that this is also incredibly useful to use later on, and with that are concluded. Listen, and I'll see you in the next one where we'll be learning how to convert from one daughter top to another. See you then. 10. Converting Data Types: Hello and welcome to another. Listen in your C shop programming course in this Listen, we're gonna be talking about darted, converting. Now, this is when we take a value from another variable and put it in a variable off a different daughter top. Now, this is easier to do than you think we're gonna be starting slow and simple with a simple conversion from a bite to an interview, both real number tops. So it should be pretty simple. Seletto start buffers. Creating a fight in a college test equals and I'm gonna give it a valley off I in the next land. I am now going to convert it to an insurgent. And this is a simple is simply placing name of the variable within the instance. See, ation and initialization line. So we've created are inter Joeckel that number? We're gonna give it a valley of test closing this column and it's a simple is that the bark value is now into Joe value. This is what is known as an implicit top conversion with their values within range off what we're trying to convert it to. Now let's take this a step further. That's great. And into jail test. We'll give it a value of something like 200 and we'll convert it to a float. One small. It's a simple is placing the variable name in the initialization, and it's 10 she ation. But those are simple conversions. Now let's talk about converting back. How do we convert an interview value into a bite? Now, of course, this is also a bit more complex, as we can have an integer value that is beyond the range of a but and this can cause errors . But they're still problem if we try to convert images that are within range soap. We know full well that an interview value is within range of a, but we can converted by doing cervical costing. Now you cost a variable. So let's test out this conversion. I create an inter jubilee. It's called a test, and we'll give it the value, too, and to convert to the bite of a created by trickle of number and to cost it, we have to create a parentheses before we give the value and his parentheses will topping fight as that is what we converted to and then we then topped independently. Want That's the value of test. Okay, with that done, what we're doing here is costing this variable test into a bite. Daughter top, and it will work the same way as we contest up now was a simple I put line, So you were converted. Now it's tested out. Typing number. 1st 1 we run a program, and as you could see, it works. Was that a problem? We've converted interject into a bite. And now let's take it even further. Brooke, Here's something a bit more complex. Such errors, a float into an integer now afloat contains a decimal top of doctor. So we're very create a throat here and let's give it a valley over, Let's say, 10.5, and we're gonna convert that float into an integer with costing so eight no equals and would create out parentheses. We want to convert it into interject within, type in a value test and close with a semi colon. Now, if replace numb within a problem, you'll see that the value has changed from 10.5 interest. Simply Tim, you also notice it does not round upwards to 11. It's simply cuts off the decimal, as if it, weren't they and puts the real number value that can get, which is 10. You have to rest Sebelius and month when working with floats and inter jizz later on. Now this is where we take it to an even more advanced way of converting data. We have talked about how certain values can be placed in certain variables because they died. A top is within range. Then we have talked about variable doctor converting. That requires casting, which is an added step which does need to be noted down. When you be working with this top of doctor. Now we're gonna take it to the next step where we take advantage of two possible methods taking advantage of the convert class and the sick and miss it being passing. So let us talk about that now with converting a string to an interview. Now, this is a bit more complex already as recon work averting a text based art atop into a number base daughter time. Of course, we have to ensure that our take start atop contains only numbers and those numbers fit the range of the doctor top we're converting it to. So let us create a string test devil quotations and we'll put a value of 50 in the close of the semi colon to convert it to an integer. We can take advantage off the two methods converting and parsing. Now the converting method is making use of the convert costs a particular method called to int. Let me show you how it works. We create our integer just as we would but instead of creating a parentheses were simply talkin convert by tapping convert. We're letting the program know that I must take code from already pre existing program would convict. Now this class does come with the program So you notice you don't have to create it like we've created this class here plus program. So we've topped in convert which lets the program find this class And now we need to make use of a message It really hard nuts. The first possible make that we're choosing the two int missing you simply topping two int capital T capital are 32 in the parentheses were will enter the value test and close the land for cynical. What this will do is take the value test worth its value of 50 through the class convert. It will then make use off a method similar to the main method we have over here, and that makes it will run through a series of code that'll convert the string into an interview. Now this is a more complex mated to understand, but it will be something you're more familiar with later on. In this course. This is for now, just a simple tool that we can take advantage off when converting from a string training teacher. So if we now test this out putting in, let's see numb and we terms apply Tim, we run our program. It prints 500. So our program worked. We converted a string from its text based startup through an Inter Jim, a number based Donna Time, and it worked without a problem. But that is only one of the methods that we will be using. The second myth it and far more common method, which will be using throughout this course, is known as parsing. Parson has a similar line of Kurt Before we enter in value instead of convert dot to into 32 were topping stopped past capital. Peake, where about Brett sees to contain the value, which is test. And there we happened. Now this is a simple message that is based on intelligence, and since it is so common, it is also the safest won. T news I recommend you use passing about the convert duck to in 32 method, and you'll notice when a run the program. It works the exact same way. But it's important to note is this is different from costing. This is converting a different daughter top from a tick space to another base, in which case we have to make use all one of two methods. The convert cross method, which is the doctor into this case, all simply pass it with int dot parts. Their differences between these two methods is nominal, so it doesn't really matter which one you choose. Of course, as I recommended earlier, you would use the Internet, not pass method. In this scenario, that being said, there's still one more top of conversion to learn any other daughter top into a stream. Now, this is a really easy conversion, and it's therefore NASA one to end this lesson off. We're going to create a char. First of all, we're gonna give it a value old That's a T test encapsulated in single quotation marks. What we're gonna do now is converted into a string and this is simply down by creating a string test equals R double quotations encapsulating nothing, not even a space plus ch. And this will work with any character. And there is old. No need to cost the daughter no need to pass it. We cannot put it and it will put a stream as you could see him. And we can do this with vintages as well. So that's great and int local it ch just to save on top. Let's give it a value of 500. Run the program at Outputs 500 and you also note that this 500 is text and not a number as we contest. Start here are trying to add 52 the value test on running a program at Prince 500 and a 58 Then now, since most of the doctor you will be out putting in future programs will be in the string dot atop this is also particularly useful conversion to remember. And since it is so easy, you have no problem taking all your daughter and creating information that could be operated as a stream A recommended practice. These daughter top conversions as converting from $1 top to another is something you do commonly in your program in Korea, and with that amount, you now have some simple building blocks to create some simple pro grips. So why you're practicing with these dollar top conversions while not test them out with some small programs you create on your own? These don't have to be anything extraordinary. But simply creating some variables and are putting and working of them will be enough practice with that said, this lesson comes doing in in the next lesson we're gonna be working with, if statements and operators and you'll find out just how important those are when it comes to Doctor in the next video and I'll see you then 11. If Statements and Operators: Hello and welcome to another. Listen in your C shop programming course in this Listen, we're gonna be going over if statements and operators now to start this listen off with I'd like to call back to previous listen where introduced code blocks to you out Curb blocks are fairly similar to if statements And if statement, however, has what is known as the claws when this close is met, the code within a code block will run. If the clause is not meant, then the code will not run in this way. We create conditional code. So depending on certain conditions, the code will run or not run. And of course, this is incredibly useful with some programs where if you have certain daughter, you want to run it through a certain process. So let us begin by creating a basic if statement first, I'm going to create an interview available where it will contain a value which I'm gonna test against different closes. You'll see what that means later on. So first things first, we create an interview variable. That's cool. It numb equals, and I'm gonna give it a very of fat closed with semi colons on our crate. And if statement as follows if print disease And after that, I'll create a set of gold brackets. Now, what is contained within these parentheses is the close. This is where we make use off operators. Operators are symbols that we use to denote a clause. For example, these operators are as follows. I'm gonna great a short commentators to list them and too great a comment Where to ford Slash is whatever we talk after this comment will not be run. It is simply put, a message left behind by a programmer for other program is to see. So this message will contain operators which are Let's stop here first we have the greater than and less than symbols which you may be thoroughly with from mess. Then we have the greater then and equal to and list. Then in equal to next, we have the equals two. Now, as you know, we already used the equals true symbol. When we're giving a variable a value. It is for this reason that to create it in a closet since we have two equals singles next to each other and as for not equals to each other, we cannot put there not equals two symbol we can put exclamation point equals and we'll be going through each of these operators now. So let us great First, a simple line of code. It tells us gift this line of could actually runs or not. So I'm gonna create a good line and I'm just going to stay test. So whenever a clause is met, it will run the code contained within this color block and should print test and output window. So let's test out the first operator with the variable very we created earlier. We take numb and let's say is greater than three. So then the clothes is simple and you can read it off, almost like in English Sentence if in, um is greater than three, and then we have our code. If this proves true, then the code will run and as we know, Father is created and three. So let's run the code and it should print test in the output window, which it does so I could is successful and Alice to stop the others. If we change the operator to the less than some boy on the program, it should not print taste, which it doesn't, and I won't weaken doubles the others. But I'm pretty sure you know the results from Yeah, let's say great to Than and equals two. It should print test, which it does, And if we put five, it does as well than anything greater. Then fire, which is numbers value. Nothing will be printed as the cause is not met, and it proves false. Now we can do the same. They with the less than and equals two. But it will have the same results, of course, being the inverse, then we have the equals equals two symbol. If it's five, it prints test. But if it's any other number, it won't predict test. And finally, the not equals two symbol, if numb, is not equal to five Print test. Unfortunately, numb is served one. Print anything, as you could see. If statements are fairly simple and they quite frankly, building block For many major programs, however, we can take them a step further. What we have done years created a code block that'll run if this close over here proves true, but what if it would to prove false and we want another line of code to run. We create what is known as an if else statement. He simply kick your off the second cold brackets and occurred block Chris, enter any topping else. After that, you create another set of cold brackets or to contain the code. So I'm gonna put another foot line here. I'm just gonna top in another taste in Sydney now, since test won't print, another test should print if our if else statement is working. And it does. If statements are fairly easy to work with and the committee used a variety of ways, I recommend you practice of the if statements, and once you've mastered them, move on to the if else statements. You'll find that they become a little complex when we go another step further, and we start working with nested if statements and additional operators. But, of course, that is to come in the next lesson. And once you feel comfortable with, if statements and if else statements, I'll see you in that lecture 12. Nested If Statements and Additional Operators: Hello and welcome to another. Listen in your C shop programming course in this Listen, we're gonna be working with nested if statements and additional operators now we know what if statements are now, if else statements that missed it. If statements take the complexity off, if statements a bit further and if statement within an if statement is known as in a Sted if statement is this because it's an if statement nested in another and this can happen several times, you can have civil in a state of statements within if statements within if statements and so on. It all depends on your program. So let us not create a program making use off in Eastern. If statement, I'm gonna create a program that will print out a certain line of text when a certain values meant Now this could be done like so I'm gonna create if statement of the close if numb, it is great to then 20 and I'm gonna create an eighth statement within this if statement that asks if numb is less than and equal to 30 then I'll have a foot line with this simple line of text once more being test enclosed in a semi column. Now this is a fairly simple necessity of statement. Any value ranging from 21 to 30 inclusive, off 2130 should activate both clauses and prove them true and then print out the string text. So I'm going to start here with the value of five, and when the program where nothing should be printed are then go a step further and I'll say a value off 31 and again it should print nothing, which it does. But if I lower that each city it prints test 21 should have sir print taste. But 20 since it's not inclusive off 20 should print nothing. So the program works correctly now, as you can imagine, nested if statements can become a lot more complex of the town, as we can be working, look different values and many number of values. Your opinions on how we want to process our doctor once you receive it yet nested. If statements are not the only way to go, there is another method we can use. Truth solves this exact same problem, and that is to make use off additional operators. Now additional operators allow us to put several clauses within a parentheses for an if statement. So in this way, we can take this close from this if statement and place it in here with this one as well. This way, we don't need the added confusion off a nested If statement Now I'm gonna create your and Ellen and Cummings. And in this line, I'm gonna show the two different additional operators be used. The first is the end addition Operator. We make use of two and symbols. What this means is we can have several closes next to each other separated by these and symbols. When it comes to working of the answer, Bols, we use them when we want to close is fulfilled. And it means birth will be true. And not just one false. And the as a true in which case we would use the all additional operators which are these two vertical lines over here. To get the vertical lines symbol you praise shift back slash price and you'll have your two vertical lands. But now let's have a look at the scenario I created earlier and make you so the and symbols we simply add in these and symbols after the first close, like so numb, less than 30 to agree with second clause. And then I can remove the if statement inside, and this will work the exact same way. No, just when I run the program with the value of 20 I think runs when I have the value off 31 . It's the same result. But if I include 2113 it will print test so additional operators work. But of course, the operator is a different kind. If we have two clauses were one or the other needs to be met, we simply separate them with the two medical loans. Now, with these two clauses, num could be any number as long as it's greater than 20. Always Andy go to 30 they fall any value. For now, we'll have the code in the code block run. So let's change it into something a bit different. If numb is either greater than 20 uh, less then 10. This means that if the value of numb is between 20 and 10 inclusive on birth, the code will not run. So if I change the value of numb 20 and on the program, you notice. Nothing is printed. Same goes if I print 10 and anything in between. So let's say 15. Nothing is printed, but if it's greater than 27 State 21 taste is printed or if its least intense. So let's say non taste is printed. As you could see with a simple additional operator. We have needed up the Kurt a bit. But of course, that only depends on the top of program you'll be working with. You may find that in future, when you're creating more advanced programs that sometimes invested, if statement is better suited for your program, then using an additional operator, especially if they're several upper glance off the civil processes that need to be run was that amount. You need to keep both additional operators and nested if statements in mind, in addition to that scene, as this is a bit more complex and you have to have taken account a lot of different mathematics to work with. I recommend you practice with ease if statements in future will be using different values that you wouldn't expect such a strings and characters. But with that amount right now, you can easily work with Inter GIs and floods, for example. And, of course, there's another daughter top that works specifically for if statements, that is the daughter top off reeling. No doubt Hear me say true or false when it comes to working with clauses has also brought up the memory off. Billing, billing values being detained, one of two values. True or false work in accordance with, if statements as well. There are many different types of code rt not, including if statements that make use off closes or with a Samant. A 1,000,000,000 variable was always produced when you compare these values. So let's say there's a clause that allows in the value of a certain building variable. So that's great one. Now let's call it taste and give it the value off truth. If we simply place test in the claws like so and run the program, it should print test because the clauses trip there is the value that is derived when you compare these values with operators and is that a month you could do the same. Yeah, So let's say if we may, bullying test equals numb, great to them Now we know now is greater than far so it should prove true, giving test the value of true. So we run the program. We noticed us that taste is printed, and if we take this away, let's make it list, then nothing should be printed. As you can see here, however, we don't often work with Boolean variables as much as you would think with. If statements it's often comes down to comparing daughter, such as Inter jizz to each other that we use. If statements with that amount this listen has come to an end. This is our first introduction into something a bit more complex when it comes to working with C Shop and you'll find that it is something similar to what will be working with in the next lesson loops. Be sure to practice, and I'll see you in the next video back for now. 13. While and For Loops: Hello and welcome to another See shop. Listen, in this video, we're gonna be going over loops now, in particular, they are two loops that were to be working with one is a while loop and the other is a for loop and you'll see the differences between both. But before we begin, we're gonna have to create a variable, which is gonna be a counter. This counter will count how many times a loop will run in cooperation with the clothes. So let us first create a inter gym, which will be I count variable and will give it the name Camp of the value off zero. Next, we're gonna great a code block with a clause much like an if statement except instead of if we're topping while a set of parentheses count, it's less than 10. After that, we create a sit off girl brackets barcode within the loop. We're gonna have a simple output long, but your output value off count like so Now the problem with this loop so far is that the code within will run indefinitely. This is because count will always be below 10. So what we need to do is ach Accounts Valley. Now, in a previous listen, we worked with what is known as an incremental This is way. A variables value is increased by a value of one. It looks as follows count plus plus cynical. This means that every time this line of code count plus plus is run counts, value will increase about one, and with it being a while, lift all the code contained within the code block will continue to run as long as the close proves true. So you just run the program now and you're not just that in our output window. Our while loop has run the code 10 towns. As you can see, they are five values printed zero to non, not a while. Loop is particularly useful for working with batches of daughter. For example, if we have 10 sets of daughter to work through, we don't want to rot 10 times the code toe work with it. So we make use of a while loop such as this to run through the code. Now, this is a fairly simple while loop, and of course, we can make use off additional operators to make it a bit more complex. Was that a mind While loop is just a basic loop that you used often enough, however, there's a second top off loop that we're gonna be working with now. This is a loop that doesn't requires to make a count. Terrible, although account favorable in particular can be particularly useful as we can insert a value into the comparable and use that value throughout. However, if we know how many times a surgeon cold block should be run and that number is unchanging , we can create a full loop, which includes the count variable. The loop looks as follows for a set of parentheses. Inside, yeah, we create an integer variable. And normally the name of this interview available is I So int I equals and let's say zero. We then create a close. So let's say I, his less than 10 once more and then another cynical on two separate the third piece code, which is I plus plus, and we then create our car broke. Now, as you can read between these brackets, we have created an interview available. We have created a clause, and we've included our incremental all in one land. Now, this is a very neat loop to work with. However, as I said before, if we are working with the specific variable, we usually make use off a wild look. That is not to say, however, that we can't make use of other variables to work without bullet. But in the meantime, let's critically. But in the meantime, let's quickly create a simple output prints of value so you could see the results are the same. However, before we do that, let's create a quick output Lancer. You can see that it works the exact same as the previous Wild as you can see him. Now, the pity on your program you would choose are the while loop or a for loop and also depends on your personal preference as well. You, as a programmer can make these decisions to find which pieces of could best suit your way of programming. But of course, with that in mind, I'm not gonna move on to another way. You can use thes loops. Let us say we retreat. A certain number offsets from a user, and we have the number of seats and month. What we do then is we create the separate variable, and we give it the value off, however many the user decides to give. With this in mind, we can create a loop that runs a specific amount of times. So instead off 10 with place set of Yeah, so we can use variables we've created earlier to our advantage within run on code. As you could see, it runs 50 times. Loops are fairly simple but extremely powerful, and you're gonna be using them a lot in your programming. Korea. In future, you'll be creating programs that will run through several processes several times. And with that demand, it helps to create a loop that'll save you not only Tom and Code, but also make your program a lot nita, meaning it's easier to code and debug now, as simple as these loops are, there can become far more complex when you start creating nested loops much like nested. If statements, we can have a loop within a loop. However, many times as we wish, that being said, I still find that these could be quite a lot of fun to use and practice with. So I recommend you do once you have a full understanding of how these loops work I'll see you in the next lesson where we learn a very important piece of code that allows us to retrieve user input. And with that, I'll see you in the next video. 14. Retrieving User Input: Hello and welcome to another. Listen in your C shop programming course in this Listen, we are going to create the long code that allows us to retrieve user input. Now, using input is, without a doubt, one of the most important parts about programming. We create applications and programs, poor uses uses. Who will purchase our products? Beauties who will make full use of those products in order to make the business or personal life easier. With that in mind, it comes down to creating the perfect application best suited for user. This is why you come across terms such as user friendly. When you become a programmer to great more user friendly applications, we have to keep the user in man. That being said, we'll learn about interfaces and creating a more user friendly application later in this course. However, for this particular video, all we got to learn it's hard to get particular information from a user. Now, this is gonna be a fairly simple line of code, but again, it is incredibly important. First, what we're gonna do is ask user at question. Simply put, were top in council that right lie never quotations in tow you name and silicon. A simple question blow. It will have a line of curd that will retrieve user input on. So don't read line parentheses, same color. What this line of code will do is retrieve what the user enters into the council window, and it will look something like this. Here we have the message we painted earlier, asking the user to enter the name and a blinking underscore letting them know that they allowed to enter event you get. So I'm getting into in a simple name. John and Chris enter, so we're now able to retrieve user input. But we need to store this value and use it in a program. So before a consul window, we're gonna create a simple variable. A string one medical name equals council. Don't read like suck. What? This would do it store the value that the user enters through a string valley in the string variable within a Put it. Now let's say another console that right land with the phrase my name is with space Plus And then we put into teeny a simple program that creates a simple line of text with the user input. So we run the program we're into in the name again. It's his money this, John and was that our program has completed its action. We're not able to treat user input and use it to our advantage. With that in mind, let's great a simple program here, where we are now, take user input. We converted to an integer, and we use that into Joe value. So let us say, were now selling a product that costs some way around $50.50. So let us not create a suitable line of text that asks the user to enter how many of the product they want. So let's say into amount. So what we're gonna do now is create an Inter Juve, Ellie. We're gonna give it the name numb and to ensure the value that the Internet is converted into an inter job. We talked it, can't not pass and then surrounded concert at Reed Land with a parentheses like so closer this semi column. And we, of course, changed the name to know. And of course, we changed the outward to something suitable. So we know the products value is 15. Fine. Oh, so if we know the practice. $50.50 within multiply to bother, really, that the user enters course. Let's beat it up. But it's to say, turtle semi colon space and tell a symbol It was the computation on a plus, Andrea. And to ensure that this code is run first to enter this calculation is run. First. We started with a set of brackets like some and now, before you run our line of code, we're gonna add the letter m after 50.50. But this will do is simply rounded off to the second decimal place, which, of course, better suits when working with currency, everyone to the work with the first decimal place would simply have no letter or the instant but CNN's we want to work with two decimal places will leave in here. Let's apply it by now Program and I always into anymore. Now let us start with Basic of my seat to, so that should give us one of the 100 So our program is working correctly, So, as you can see, we can now retrieve user input. We can convert it to any value we want. We can work of that doctor to great information, which is then a ported in this are put on here. And of course, this information is particularly useful so we can create other programs that were cannot say yes, no base. So we ask the user to enter their age to Yes, no question. So that's a, uh you older, then 20. And then it's have a set of brackets. Yes, No, like so with install this valley in, let's say, a character variable charge, CH. Said. Rent Disease Council. Not really lan. Great disease close with Simi Car with increased. And if statement that asks if CH equals equals a single quotations line and it say Why for yes Get in, Princess. Hey, right, One simple message saying you 20 and we'll create an else statement. Yeah, but its own code book with its own code book. And it happened like this. You 20. So now let us take start this program, but asks a superb in 20 if we put in why it says you're older than 20 so a program works. But now that our program is becoming more complex, we have to take in mind the different types of daughter a user might enter now instead of if ch equals equals Why? What if the internal lower case? What were they make use? Often all symbol ch equals equals Why? Encapsulated in single quotations, we create an else if statement now way it ch equals up The case in full ch equals equals lower case. And that's a sad X equals symbol that might give us in here. This is your 20 younger else. And now this is if the user enters in, daughter, that does not work and in this case will simply up put a basic area for now. Right? You're wrong, Doctor. Now we have a far more complex program, but certainly one that is more use of Bring Lee. So we're in the program. It's intended lower case wa it does work. Let us not into In lower case in, you're you're 20. It now says your 20 younger so it is still working and I'll let this one upper come again. And instead of yes or no, we're gonna just put in another character such as six, and says you enter the wrong daughter step by step. We're creating a more complex and user friendly program. But taking in using input, analyzing it with its statements. We can, of course, make use of groups so that where the use asked to go through this process several times they get into the number of times they want to go through it. And, of course, we can create amazing programs of just a few lines of code. And with that said, it is not time to practice this code. Consul dot reid Land Great small programs such as this one work with it with loops. And if statements tried, different types of dark tank averted into those right doctor top, so you can work with them. I once you feel comfortable enough to move on in the next video, we're going to create out first project. I'll go through this project with you, and then I'll give you an answer to work with as well. And with that, I'll see you in the next video 15. Project 1 Discussion and Answer: Hello and welcome to the first project of your see shop programming course. Now, first I'm gonna be going through what your project requires and what that I'll be providing you with an answer. So, as you could see, you have really created the project in advance and I will be going through what it requires . You should see the details come up on the screen as I say that you are gonna be running a theater. So you're gonna create a program called Ticket Tester which would taste the age off each person coming to see a movie that is rated 16 and higher. So is that a month you're going to get the uses, name and age, and they're gonna be five people going to the film. So you have to keep track Five ages and five means What your program will do is ask the use it first contain the name and in the age and depending on if the user is 16 or older, all younger than 16 0 print art. The following line The name is not in our entry. All the name is an art entry opinion on the age. Once you've reached the end off your five sets off, daughter, you're going to create a final output one which outputs the number that were not allowed entry another which puts the number which were allowed entry. And finally, a percentage of how Maney could watch the movie. In this program, you are to make use of the loop. It can be a while. Lip or a for loop. That is your choice. But you're early to make use off one if statement in your program. So the first step is for you to create your project. Name it ticket tester. And then from there you're going to retrieve user input. You're gonna start in variables and you're gonna output the final result. I recommended you pause the video here to create your program as shortly I'll be showing you want solution to the project. Okay, Now, we had really to go through one of the solutions to ticket Tester. The first thing I'm gonna do is create the variables which contain certain daughter. First, I'm gonna create an inter variable and I'm gonna call it Entry equals zero. I'm gonna create another one, call it. No entry equals zero and then I want to create a string name with no valley right now. And an interview variable called age, which also have a very not that great to those variables. I'm going to create a full loop hole and I equals zero. I is less than far. And then I bless. And now, in the curb block, this is where I'll be retrieving user input. And I'm gonna be processing the doctor with an if statement within a look. So the first thing I'm gonna do is ask the user to interning, and they're going to store that name and the string. Very creative. Ilya name equals parentheses. Next, I'm gonna ask for age, and I'm gonna store that agent through the interview variable, which just requires me and passed the information that the user enters, Like so once that's done, I create an if statement which will take that dollar first. If age is greater than or equal to 16. Council right. Don name plus double quotations. Her line allowed entry as they are old enough to see the movie. And I'm gonna add two entries value with entry plus plus. Next I created else statement with suitable. Asked what name Devil quotations. Karlan No. Sydney Carla in the line of code. And then I add to know entries value with the plus plus. And that will be all the Kurd that our place inside this loop now off the loop. And if statement complete, this should take care of all the results as the users entering the doctor. But for the final result to create after Luke consulate, Right, Fine. This to create a space in the thinks is council about right line coming to put in the no entries first as discussed, do the same entry. And finally, a percentage of how many made it into the program for this. I'm gonna create I put right, huh? I'm gonna take entries value times that by Twinkie to get that percentage then at the percentage like some good luck and close to this in the car. And with that, the program that should complete this. So ask the user to anti involved names and ages. Suitable output after each name Now add to each value for injury in the entry which will go towards the final output. So let's run ticket tester now and test it out. So I'm going to be using example values that will be appearing on the screen now, so that's just it. Out with John. With age of 20 John is allowed entry next to try Jane, 15 who is not allowed entry. Joe, 16 who is allowed entry during me 17 Resalat entry. And finally, Jasmine, who is five. There is not a lot entry and the final output to are not allowed entry. Three are lot entry. 60% could watch the movie. So is that the program ran successfully. Now, of course, there are many ways one can create a program. There are different parts one can take. You could have made use of a while you you could have made use of to if statements, you could have made use of additional operators and showed the several ways that you could have done this program. So if your program works with the same number of plans or less, then I would say that you complete this project successfully. However, if you struggle to complete this project or find that you're used too much code or encountered more than a few errors, then I recommend going over the card I used in this project. In addition to that, this is not the best answer for Ticket Testa. There are several ways you could do a program, and there are several ways you could do better than was that in mind. You can create a more structured and organized output. You can also save yourself some lines of code by instead of creating several, Insua can separate them with commerce such as this. You could also include which name is being entered so far putting in the output. So this way we know which sit off, doctor that we're on at all times. There are various ways you can make neater program, and I saw a more efficient one. With that said, that does conclude the first project for your C Sharp course. I'll be enjoyed and found it useful. I hope you enjoyed and don't struggle too much. And was that said, This video has come to an end. In the next video, conclude to what you have learned in this section of your see shop programming course. 16. Conclusion to C# Programming: Your Beginner Guide to Basic C# Code: Hello and congratulations on completing the first section off. You see shop programming course. Now the beginning section contains all the information need to know before you move on. Within this section, you've learned some basic code, such as output and input. However, you'll find as you work with more advanced programs, that input and output are one of the most important things to consider when creating a program. It is with the input of the user that we can create amazing programs, and it is with the output that we can use our style in flee to give the user what they wish , be it more organized information or wonderful interface to use for helpful program. All of this is incredibly important. Now, if you find the course difficult in some areas are do recommend going over them. It doesn't hurt to get more comfortable with the language that you're learning. See Shop is by no means one of the easiest languages to learn, but it certainly can be mastered if you give it enough time in practice. That being said that you have reached the end of the section and you're ready to move on to Section two we will be working with more advanced code. However, it goes without saying that the beginner's section is one of the first and most important steps you must take in this course, as the beginner code will help you get a good idea of what you'll be working with as a C sharp program. You learn things over time, which are grain more complex, and you'll find that changes over happened with each update. However, what you have learned in this beginner's section will be with you throughout it. And it is from this beginning section that you can also decide if C sharp programming is for you. But I hope by the end of this course you found that it waas. And with that Alan this video and which he like with an egg section back for now.