C# For Beginners - Make Windows Apps | Frank A | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

C# For Beginners - Make Windows Apps

teacher avatar Frank A

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

31 Lessons (2h 8m)
    • 1. Overview

    • 2. Why C#

    • 3. Install Visual Studio

    • 4. Create, run and understand a program

    • 5. Text output in a console window


    • 7. Text Input in a console window

    • 8. Variables

    • 9. Numeric Input in Console

    • 10. Hello world

    • 11. Button

    • 12. Textbox

    • 13. Arrays

    • 14. Loop through array

    • 15. For Loop

    • 16. For loop - multiplication table

    • 17. While loop

    • 18. Do While loop

    • 19. If statements part 1

    • 20. If statements part 2

    • 21. Functions

    • 22. Functions return variables

    • 23. Read Text File

    • 24. Read Text File into Array Combobox

    • 25. Write Text to File

    • 26. Menubar

    • 27. About box

    • 28. Run External Programs

    • 29. Personal Newletter Generator

    • 30. Image Viewer

    • 31. Web browser

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

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

Learning to write code? In this introductory course you will learn C# programming. Upon completion you can make basic Windows apps and understand the absolute basics.  This course contains clear videos that take you through the basics step by step.

The great news? You won't need any specialized knowledge to get started. 

You will learn the C# programming language including:  C# code (operators, C# strings, C# list, C# array, for loops and more). We  also teach you how to get started with visual studio c#.

Meet Your Teacher

Teacher Profile Image

Frank A


Sharing my experience in Technology here. I have a background in Computer Science and worked with nearly every programming language on the planet. I graduated with highest distinction during my masters program. I've worked on projects ranging from Robotics, Web Apps, Mobile Apps to Embedded Systems. These courses will help you achieve your goals.

To your success!

See full profile

Related Skills

Technology Data Science

Class Ratings

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

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

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. Overview: the goal off his courses to learn to make Windows. EPPS. We will start with the absolute basics. It's just the insulation of visual studio. We'll teach you how to create run programs, how to make basic critical applications, and we'll go deeper into the sea. Shop language will teach you about a race. It aeration selection, functions, files and more. My name is Frank, a computer science graduate, and so far engineer I've worked on many C sharp projects. 2. Why C#: it's pronounced C sharp. It's a programming language, so it's a language to create programs, and it's great about Microsoft when you want to make Windows applications. This is good language to choose. So various things are made with the programming language C sharp, including desktop applications, a lot of websites and a lot of games using the Unity three D engine. Some examples. Pain dot net It's a pain program. Keep us possible management program and lows of other programs. Some may tweets she shop. So the great C sharp applications you need visual studio programming environment, and it's created by Microsoft's so you can be sure that the programming environment is always up to date to the Microsoft platform windows. It looks like this, and in the next lecture, I'll teach you how to install it. 3. Install Visual Studio: open up a Web browser to just grow and type Visual Studio Express. Go to the downloads link directly. Sorry about that and go with the community version. Press free downloads Open up to sit up. I mean, the meister Brau, sir. In the meantime, so to set up is lunching, and this might just take a while. Now you'll see the installation directory. It's accepts seven gigabytes on your drives quite a lot to install the whole and development environments. Install C Sharp and other stuff. So just go with default and present stole Press. Yes, and now it will install official studio, which will take a while seat, downloading all of the packages and installing and now get back to you once we're in the next step. If everything went well, you'll see the screen and you'll get an option. You have to restart. Ah, win this computer. Once you start official studio, you'll see this window pop up. You can select fell new projects and you'll be able to create C sharp applications. You'll see all kind of things here so you can create the windows for MEPs. Issue just graphical application or console. So let's go with Windows forms for now, creates a name for your application inside the project directory and press. OK, we'll create the project, which will take about 30 seconds, and you'll be able to create a visual map as well as his coat. So if you press run, you'll have your first application, which doesn't do anything except show graphical window. 4. Create, run and understand a program: If you start visual studio, you'll see a screen like this. No, we can. We always start by creating or opening a project. Press foul new projects, and you'll see this screen pop up, in which we can type different select different types of projects, which is a console application. A Windows Form application, which is a graphical application. You'll see a sp dot nets, which is a weapon, and if you scroll scroll on the list on the site you lost Cedars, Android Clouds, IOS and no kind of things not to create an application. Select the console application and type a name for projects on a simple program. And this is the directory or your programs will be stores so you'll find your execute. Herbal will also be in this directory. Slash the name off your projects in this case, simple program. So you just go play this for now, Prince okay and see all kind of code appear, and if you breast start, it will run the program, which does nothing and exits directly. Now if we go to the Explorer so the directory just created flesh. Simple program. You'll see all off the fells, and she sharp creators. So there's a fuller called simple program and all kind of sub program. So this is obviously our code fell. If you re size this a little, you'll see program CS. So, Alice, the project fell. So this fell. It's simply this fell, which is the goat. If we go into bin directory De Buck, you'll find we have the program here. Simple program, which doesn't do anything exits immediately. So this is where you find your program inside the bench, less debug, director. Now de Bock is a face in which you're still developing the program. We also have a release face. So when the program is finished, you would put it in release, and if you press start 5. Text output in a console window: we create a program that outputs text, so press foul new projects. Select console application from the list. Be sure you'll see diesel C sharp on the left Visual studio supports multiple programming languages. So be sure to select C sharp and select console application. You can type a name for your projects here. My name is hello World and press OK to create the project. Now what you see on the screen here, right after you created projects is a lot of coats, right. So you see all kind of commands here using and then the name space class and a line of code here, which is actually a function definition on the function it's called Made. This is where every program starts and the or recognize the function might ease breakfasts . So in between our para meters, in this case, names are a RGs, and these funny symbols are beginning and symbol. So this is the begin off the program and this is the ends. So you'll notice nothing happens because this is begin. This is hands, so there's no cold in between. And if he were to run this program, you see it immediately exits because it doesn't do anything. No, we can ask it to get a key. So press answer right after the begin symbol type console reads. Notice these suggestions start to pop up once you start typing, so we'll ask for a key. Don't forget to add to semi colon on the ends, so if you spread, start to see the program keeps waiting because sweet types comes older. Three. Ski So it's waiting for us to type. A key can be any key, and when we type the key, it will just exits. So let's press a key and you'll see it exits. Now is it mentioned? We write the program in the main function between these records, so they begin and end symbol in here. Weaken site console. That's right, Linus Well, which will output text of the screen, for example, The type Hello, You know me and know T to enter line with this symbol again. Press run start and you'll see the text appearing on the screen. So the line is consul not read line, whereas the other one is console has read line. So you notice. In this case, a lot of things are done with the console in front. Write another line in the same way. If you press run, you see two lines of text appearing. Of course, you can create Ah whole kind of artistic screen if you want. So at some decoration it would appear on the screen as well. Right? So there's just a few console right line, of course, and notice. These are all functions. So they have those records again. And then here we have one para meter, which detects so the same for just one bar later text. Barometric Take. So all of these are function calls, and you recognized that based on those records, and sometimes there may be arguments in between, and sometimes there's not. In this case, there's and arguments with line text. 6. Comments: in any C sharp program, we can add comments in the Commons. It's simply text inside the program that it's not executed during the program. For example, we could type something here and you would think it would conflict with the rest of the program. Right? We type some text here, but it does not because it is exactly a Commons. So type does flashes in France and you have comments so you can at all kind of comments. You'd run it and see it doesn't affect the program. It'll and you can has many. Coleman says she wants now. These are single line comments. So if I wouldn't type those lessons in front and just continue typing, you see doesn't accept it, so it needs to. Slash is in France. Now, if you want to write a big story in there, he wants type multiple lines and you probably don't want to be typing the slashes each time . So as a multi line Commons that this symbol to start and it will automatically at for multiple lines and so on impressed this same slash to exit the program. So this is a multi line Commons and it's a much easier way to at multiple lines of texts this way, then the other way, because you can just continue typing now. Comments are not edit for programmers toe to play around with the coats. Usually they are explaining what a function is doing or why it's there what the programmers trying to achieve with that particular piece of coats. You'll often finds they're used for copyright as well. So you might see on top off the program, sometimes even up here, like some copyright noticed and so on, as well as a license. There was sometimes put that in the cold as well. So you see comments used for no stings, mainly so mainly copyrights and not or as well as what's programmers trying to achieve with a certain function. So in this case, it would be example program that outputs. So you see, the comments can be add it in the in the program, and they can be quite useful as well, especially when you have a very large program. And then you can when you read someone's else program. Do you have additional text to understand the program 7. Text Input in a console window: well, great a program in which you ask for input. So press file new projects and we let the program ask for a name. Yeah, remember, this is the begin symbol. So we started the program here, and so will type console that's risky, as well as the parentheses and the colon to prevent the window from closing. If you press run and see the window stays on the screen. No, Well, I put it, We want toe. They used her to answer a name otherwise used to may not know what to do in this program. Now, if you to run the program, it will just out boot. And if you press a key, it exits. So to read a line together line simply tap console that's read line. No, we can run the program and Seiple name and then press a key program. Wilder and Exits. Now, to get the name, we need to have a variable in which we can store it. So let's say we have available name, off type string and string is just text, so we'll type name it's console at the red light, and then we could say console right line. So what's going on here? Well, first it outputs and the question enter a name, then it gets a line from the keyboard and stores it in the variable name and name is off the type string, which is text. Then it outputs another line of text. It says your name is an outpost of arable name, and this contains the text, but we just rest from the console. So this is just a variable. And then we read the key. So if you run this program, type your name and you'll see it outputs the name right there. I notice it's dust prints, the question and the keyboard input on different lines. So instead of right line can also type right. If you run the program, we can type on the same line so you can enter your name and tells us the outputs. So in this case, the fair Boys, Frank, because I typed it into keyboards, so a terrible name was contained. Frank 8. Variables: she sharp supports all kind of parables. So let's make a console application. Select guns all press enter the first thing we'll do to make sure they happen US and directly exits time risky. If you run the up, you see ah, terminal window, the press a key it exits. Does it mentions? We have different types of variables. For example, we could have a variable name. The type text and text in C. Sharp is called String. Now we can help attests to the screen. If you run the program, see text appear, so string is simply text. Now there's other terrible types. For example, we could have a variable H off the type. Integer, which is a whole number, can print it to the screen as well, right, lying H. And in this case we can directly print numbers to the screen to screen. So we need to convert it to check and sixties a string. So we convert number to text to string Brendan to the screen. So now it's output to the screen. Now integer is a whole number, so you can't go and 3.5 and so on. If you want a number with comas with numbers behind Tacoma. There's another temple for this, which is called the Float, and they always end with an F. You can print its to the screen as well. And of course, it's a number, so it needs to be converted two texts, So this will remove this line here. It's what I put the variable X off the type float, which is a number of with numbers behind to come on. So if you run it, you see it has numbers behind two comma. Now you can do operation with its, so let's say you have another variable. How you can do exploits were why, and you can do some off the string now. It sounds excellent. Why you can do various operations can also do multiplication. It's one thing to keep in mind his debts. Floating point numbers are not, except if you will. So if you have a number which has a lot off zeros in here, and the one might be that C sharp ignore States has shown here, So it's not exact. But it's a way to deal with numbers behind the comma, and if you want to be sure you have exact numbers, just use entered your sore strings 9. Numeric Input in Console: We can also get an American put and to get numbering and put, we have to convert text into a number. So first created new projects console application and so I'm going to name it formula. Now. First thing to do is go in the main function right after begin inside, risky to prevent a window from disappearing. So if you to run it, see it excess when we present key. Now let's say we have a linear formula, so I equals two times X. So we need to gets X right? So we take the texts. If you run this, it wouldn't ask any key input, except for the ones or exits tells us enter variable X. He pressed something it exits and we want so gets that value consoled read line and we want to store the text so I'll name creates a favorable six, which is off the type text. Now you might wonder why I'm storing thesis text and not hysterically getting storing it as X because we're asking for X. The reason is when you get this hits stores, text literal text in the computer and not as a number of value, so in order to have a number Rick Value. We need to comfort the text into a number. No number of terrible is defined as this. So it's an integer 12345 and so on. And the name is X. So you consider X, which is equal to Doc Parse text. So discomforts the text, which is keyboard input to an actual number. She's X, and we can end Use X in our program is a number of value. So if you run the program and get inputs, so let's say access for it doesn't show anything after it, because after we have the variable X, it just exits so we can say Red Line X. Let's say we type three and see it's three. We could go on and say two times X three times x five times x So you know that this X is a number of variable because we can do much medical operations with it, and you can do that with text. So let's say we type X history and you see the output for all these much of medical operations here. You can also do this in one line, which is a little bit more cryptic, but you could replace sex with console a three line. Remove this line. Yes, well, it's this line. So now it gets the console keyboard input and directly. Parsons is the output off dysfunction into death function is perimeter. So this looks like a bit more confusing. But all it does is gets a number of value x from the keyboards, any number that it would make the calculations. 10. Hello world: we start by creating a basic application which shows hello World to discrete. It's a press file. New Projects takes a second to loads greater Windows Form application for yourself. Give it a project name. Come to name it Hello World and notes. It's being grated in this directory when we press OK press OK takes a second or two to lows to initialize the project and now you'll see this. So if you press run in, just Children empty window, she's building the application takes a second or so. So here we've got our window and we want to make a show. Hello world. So first thing we can do is change this title form one It's not so she beautiful title. So if you double click if you click on the form and go to the right you see text here and you can change your title so you can make some title that you once. If you press two books, I see a lot of things appear If you scroll down to label, you can select it and drag it onto the form label is just text. So if you'd run it like this a season text appearing You can change the text in the same manner so you'll see text on the right here, Change it to Hello world. Now if you run the up, you got your first hello world up. They made one to have a larger text. It's quite small if you scroll up here, you see phones appearing and if you press on the small dots here, you can select the phone size. Maybe want something bigger running. It will see a vague hello world message and the small dots allow you to resize the window. So if you just direct them to change the size might want to have this here besides it. So there is. Though we've made the first hello world up you go to your projects directory. You can also find the execute herbal in there. If you go to the project directory, you'll see which is a documents fizzle. Studio 2015 slash projects see hello World Cup And if you go into the hello World directory in the bin Directory de Buck, you'll see the execute Herbal Hello world So if you double click it will start Yep. You want to send you up to your friends or something 11. Button: in this app will greater button, which reacts when you click on it, create a new projects. So Windows form application again. Choose a name for your projects. I will call it but an example and press enter no press. OK, It takes a second to creative projects CD form again so we can go to the rights. Find Tex changed its idle and go to two books. Select a button. No notice. You have thes whites, dots appearing so you can resize a button. Depending on the size you want, you can change. Create any size. Whatever you said she wants conditionally decided now on the left. Here can. So said the text on the buttons analogy. It's social named text. Go on, name it, Click me, and if you scroll up you see it also has a name so you can name your name your button. Conclude name it's example Button. Now, if we run this broken, it's shows the up on the button, and if we click, nothing happens. So we can change that. If you double click on the button and we'll start to show some coats and this coat is actually a function so you'll see the name example button Click here, which is so easy to function, and you see some strange symbols here. So this is Begin off the coat for that function, and this is the end. So we contract one line of code here, which shows a message books. So simply type message books, not show, and then type your message and make sure you end the line of code with the semicolon to diesel. So once it's clicked, it goes to dysfunction. Example. Button Click. This is the begins, think symbol, and it shows this line. So let's try it out. We have our up here pressed a button and you'll see it shows the message books. Now, if you want to go back to the designer, they will have on top. You can switch between the design and the coat. It's something to quite useful, can always go back and forth between coats and design with these buttons, or alternatively, you can double click on the button and goes directly to the coat it runs when you press the button 12. Textbox: this tutorial will make a slightly more advanced application. Should be going to making up, which has input and reacts when you pressed a button. So let's go toe found new projects Windows forms application. We're going to name it's example name. You can pick another project name if you wants breast OK to create it. Now you'll see this form appear and in this up want to ask the name off the user. When the button is pressed, we want to show that name. First thing to do is to change the window title. Don't want to have a program with form Oneness Name, so name its name EMP. Go to to box search for the textbooks directed insights. It's slightly bigger, so a text books you can type text in sight. Whatever text you once press on, it helps. You can set the default text, so if you say OK, it's already filled in. But it's probably not what you want. We want here. We can also scroll up and name. It's instead of textbooks. One going to call it name fields. I also want to label Sen director label on there. See text here, change it to name so that when the user starts to Yep, no. Said it actually has to type their name. Then go to two books again. Scroll up to find Button. I had it in there. You might want to consider where you place the button could make it large. Well, you could make it small. Place it anywhere in the window. Either way, I'll make it decides just for the example. Resize the window. Using those dots. Select a button again. Something on your button if we double click the button. Health is where you see the coat again. And remember that we could do message books that show text and end with a semicolon. So if you run it, see this program press OK, it's he text. But instead of sex, we want to see the input name. So go back to the form, select the books and notice we named it Name Fields. Come back to the coats instead of text. I will say name Fields does named futile text 13. Arrays: in this election will go into a race or list goto foul new projects and will make a console application this time. Name it list. Example. We can define the list off any type of variables. So, numbers or text, let's say we have a list of customers could define it in this way. Between these, you can add, you're different customers and so on, so it mind ones heads risky. Make sure the program doesn't next. It's and we can use right line. Show the entire list so you'll see it's It's an array, and that's why our A list. That's why it doesn't know put like this. So to output, it's We need to use the for each loop like this, and we can see right light so this will output every item in our customer list. But this is our customer list. Know that we used these brackets for a list, so if it's a single one, it's a single variable and ever used his brackets. It could be a whole bunch of parables to run the program. You see all off, the customers are printed, and you could out more if you want whatever names you want to put in there. If you run, it's see all of the items. Sprint. It's of course you can fiddle around tweets, he called. Between those brackets, Let's say you could have a customer in France and you'll see for every line in Princeton. It's not specifically required to have texts, a list of text values. You could also have a list of numbering values. So let's say students course. And they could be a bunch of numbers, right? Let's say Europeans course So a number between zero and 10 and so one. And for every score in the list of scores, it could princess to the screen for each. Now, if you'll run it, you see all of the scores off that list printed to the screen. Now we can also access in video items we could, right? Let's say we have a list off students names, whatever name she went to put in there. So a list or an array of student names we can print an individual one. Let's say we bring the first item. We would use the same records again and specify a number, so zero is the first item, so that would bring Jack. That's because the computer starts counting from zero. So zero was the first item. It's maybe a bit confusing at first. So if you type one will be the second item to be this one. Jeffrey. So that's how you can access individual items if you don't want to go through the entire list, you know, simple. If she liked to, would be deterred. Item. Now, Obviously the number needs to be in this list. So if you specify 200 it will and not work. When you'll get strange outputs it seats. They're loading a long time and not working and you'll see the error. And the arrow is there because there is no item. 200 right? So you need to. So the number needs to be between zero and the size of the list. So in this case, the four items. So between zero entry. If you specify its re in here, it's what showed a fort item. That's how you toy around with list or a race, as they called 14. Loop through array: and his lecture will demonstrate the for each loop. Many occasions you have a certain list of items, for example, list of customers and you want to do in action for every customer. So let's do that greater project we knows form application. I'm going to call it customers. Now go to the two books and at a combo books. Now inside the combo box, we could can at all of our customers. So if you go toe items small dots here you can add every customer one by one and so one. And if you scroll down to text, you can set a default item, and you may want some action button. So if you had a button go, you can do something for each customer. If you simply run it, see a list of customers you can select. One can press go now. Obviously, you can get the value off this textbooks and show it on the screen. But you can also do something for every customer using for each loop, time for each, and then we need to who have available customer off the type. Text and text is always shown a string, and for every customer in these books, and the books is called Combo Box one dot items. Now we can do something for every customer in that list. So now if we would breast go, it was simply output the name of every customer. See? So that's just all of the customers, and you can do something specific. For example, in this block off coach, you called on the message Children message to the screen. So this is how you go through a list of combo box items. So for every item off debt type, using a variable and for every rounds or for every message books, this is shown so these two lines of coats are executed for every customer. 15. For Loop: this lecture, you will learn how to repeat cults. Given some cold, you can repeat the action number of times. Make an example. Great. A new projects created the name going on the right. You can set the name is always and we're going to say this. Can you name the program joke and comes at a button which the value Click me and may remember when we double click on it, you see the actual function coat and you concise, measured spokesman show clicked. Now we have one line of code here, right? And if we press the button, do you call this function and show the message books? Let's run the program, press the button and you'll see message books. Now we can repeat this number of times this line of code using a for loop so we type the word for then we need to step said to start, and we need to have accounting variable, so I'm going to call accounting Terrible high, and it's going to do it 10 times increments, my one. So if you do buy one, usually use I plus plus. Now, if you run the coat and you press the button It will repeat this block of coat 10 times, but we start counting from zero. So it probably will be 11. 123456789 10. Okay, so 10 times. And you can also show the number two showed a repetition. So every time this block of cold is repeated until variable, I is equal to 10. Let's just run again. 60 You see it start counter from zero zero and it increments into repeats. This block of coats. No, you're not restricted to a single line, so you could do more calculations in here. All right, so let's say you have put your name in there. And so now we have two lines of cults and it will repeat these lines of coat until this condition is true. So let's say we put it to five, and now you see 01234 and you see it didn't go toe. Five starts counting from zero also, so that's a little bit confusing. So stop the program, set it to one and going to run it 12 Tree, for now, five is not included because it needs the equality sign. It's run it again. Seed counts in, Does it five times, repeats the coats starting from one. So with this line of codes, you can repeat a block off coat a number of times. So this is the increment values increment by one, and it's increments until a terrible I his five. And it starts from one very base, So to repeat, cook many lines of code. 16. For loop - multiplication table: and this actual show you how to repeat cold. So we're going to create a new project. Um, new projects, Greater Windows Form application. Now I'm going to name it Multiplication table. What it will do is his calculate a certain amount of time. So repeats in action a certain amount of time. There's two marks, two ahead and input fields. I noticed it. Want to text appearing on left? Change the name. It's called Sex Books one. Okay, it's textbooks. It orations. You might call it re patients or number of times that it will repeat with the label in there going to change the text port. Sorry, but some text in there, so I just directed down the little simplified the text. I'm going to add a text books to show the output, and the textbooks will contain multiple lines. You have an option. Multi line here said it to true, and then you can direct is down. You can have multiple lines now. We also need a button to make the broken starts. So start button called the button. It starts in the name off the button. I'll also called Start, so when the button is clicked it will get how many times from this books and then show the multiplication table double click on it. First thing to do is to get the value off the books number. And we called the books textbooks, alterations, no texts and notice. We haven't all text, and I actually want a number come to change it. Interfere, which is our variable off That will be off the type number into here, which is a whole number, and we cannot put text in a number. So we have to convert text to, ah to a number with parse into the course, which converts or text value to a numeric value. Then, uh, we want to way could show it to the screen if you type message books. Show number two String cause message books only shows text, not numbers. So now it would show the value. If you run it. Two lines of code say five times. It tells us five. If you will type three, it would say three and someone. So now we can use the so called four loop to do the calculations so you can step four. We need a variable to count. I'm just going to call it high and you used to plus plus to increase so dismal it might look a little with cryptic, but all it does is repeated this block of coat so it starts counting from zero, and it stops counting health number, and it increases by one. So in here we can type See what the books was called textbooks one. Then we say high times number to stream. So if you run the coats and you type a number here, let's say five. I noticed that all of them appear on the same line, so we're going to add a new line five. Now you'll see the multiplication time. So we select the number and his calculates one times 52 times five and someone we can actually showed awful. Some in there, like a little bit more sense. If we type five here, you see zero times 51 time five and so one. If you type 20 you see zero times 20 and so on. So we not only want to show the amount of times, but also which table. So we would need to feels move this down a little, which is the amount of times and the table to write another one ends. Put a label in there. Okay, how this is called the textbooks table and the other is for the amount of repetitions. So we'll have one called table and one that is the number off repetitions. If you render codes, let's say 10 times. I want a table of three and C zero times 31 times three to chemistry and so on. We can change the table seven and you have a table of seven. And I do note that the Texas not clears so we can actually create a text before the loop. No, we can specify the amount of times that's a 10 times tree table of three. Or we could say Table of five. Notice that the table is clear so we get a whole table here instead of see the previous apples Table of eight and you're gonna go on a cunning easily increases to 100 times and you'll see the whole table toe 102nd time is there well until 99. So to get everything you not only say smaller but smaller or equal to which would include includes the last one So if retired one hundreds hands table of three, you scroll down. You see 100 in there as well. Now it is. We don't have a scroll bar press on it. And this is crowbars. None. You can select vertical. You see his girl bar there. People safe when, Let's say 10 times with table of three. See, we have a little scroll bar on the site, say 50 times and it goes on can change its able if you want. So let's say table off 9 100 times and you live the entire table off nine. 17. While loop: We may not always know how many times a certain piece of coats should look, for example, when asking user input. So that's down straight debts going to get a new project until name. It's guess number. Now this is a console application, so offer Stipe console risky to prevent the window from disappearing. And now we're gets a key. So let's say we have a program that asks, I guess the right number. Now, if the number is not correct, it should just keep asking. First we'll get the number, and while the number is not correct, it should keep asking number. And of course, we need to find the correct number or the guest number. So let's see the lucky number of seven. So what we're doing here is creating a while loop, and this will repeat this coat until X is equal to the correct number. So if you run the coats, I will ask us for the number and notice it doesn't put it on the right line. So instead of right line type right, run it and it will ask us for the real number. So type the wrong numbers. It just keeps executing the coat, so the while loop is used when you don't know exactly before hands, how many times it should be repeated. In this case, it should be repeated forever unless they were correct. Number is kissed, so it just keeps repeating the coast unless the condition that you specify between the brackets, his medicine and this could be forever if it's never guessed. 18. Do While loop: she Sharp also has another type of Floop called her Do I look? So if we create a program can be any any type of program, we could create a loop which stars execution directly, so you got to have. So it starts doing it directly while a certain condition is met. So, for example, wow, terrible. I is smaller than 10 and we need to define and available I now this would look forever because I remains zero. So if he'd run this program, you see I is always smaller than 10 because we don't increment it. You see, it's just going on forever and ever. It could cite eyes I plus one. So we increments I inside the look and this woods make the condition end, so just type risky here to prevent closing the program. You'll see it brings several times, and it starts printing the output before the commission is checked. So, for example, let's say ice 12. It would still execute once because it starts checking the condition on the end of the loop so it always executes the block at least one time. This is a difference. Wait a traditional while loop 19. If statements part 1: we'll make an FDA. It asks for an h great a new projects. Windows forms up, and I'm going to call it a chep, said the title of that. Go to two books. Search for a label. So once the user to enter, he saw her age and we want an input field as well. You can just take a textbooks a little bit bigger. Give it a good name. So I want to have some submit button on a safe button. I'm going to call it okay, resize it to be a good size. No fue shave it and run it. You'll see we have a basic updates. Ask for an H. We enter something, nothing happens that's changed its So you want to get the value? This books she's called textbooks H city type textbooks age the text and the type of terrible is text, and instead we want to have a number once a variable type institute whole number. But we can start text in a number, so we have to convert the number to text text to a number, so we type institute the parse. So this line reversed the text through a number and then stores his into the variable H. Now we could show that to the screen, but in this case we can't directly show a number to the screen. It needs to be text, so we would have to convert the number back to text. Can do that using the variable the function to string, which can first number to text if you run it type of number. You see it's converting the text to a number and again number two texts and shows that on the screen. Now why do we want to convert between text and number? Because we can enter invalid numbers? Let's say Rh, we could enter here 1488 and it will just show that so we want to validate. That is number. It's correct. The eight should be less than the maximum eight's. A human can live, so we could say, for example, if each H smaller than 130 we want to show the message. But if it's not smaller Joe, some error message. So no, it checks the defendable H. So whatever is entered in the books, if it's smaller than 130 it shows the age. And if the case in the case. It's not smaller than 130 gyms to this block of coat and says, Too old. So let's run it and we type some H 64. It's fine. So it goes in here 18 64 64 smaller than one under 30. Show the books and then it's continues after this block of coats. So there's no Coke left? No, In the case we enter a bigger number. So let's say 156. It gets the age from these books. So Hs 156 about 156 is bigger than 1 30 It goes to this block of cult and shows the error. So you see the arrow message? No. Now this thing is called an if statement because we use the keyboard. If here any time you see a computer program with, if it makes a choice, depending on some conditions. In this case, the condition is age smaller than 1 30 But it could be any condition, and you can you, and then it's executes either this block of codes or the other block off coats with an if statements. The execution of coat is always optional. It always depends on the condition 20. If statements part 2: We will make a program that shows different output depending on the input. So we will be able to enter a name. And if the name is a certain name, it will know something specific takes go to new projects. Your name, the project. Hello. So Windows forms application. Now we'll be able to enter a name. So at the label with the value name the textbooks going to call it textbooks name. Make sure you set her name. So it's called Form one. Name your application, so whatever you want to call it. And finally, we aren't a button so similar to the program we made before set to fail you to submits or okay, whenever you want to call it to drink it down a little resize. It's now if we press the button, we want to get the message or the name. So it's textbooks. Name that sex so he gets the value off these books, whatever is in here and then we want to show it. So message books that show name can run the program. Enter something in this book's example name You see your name appearing now we can also show a different message depending on whose name is entered, for example, you might want to show a different message for a specific user. Let's say if name equals toe Washington might want to show Hello, Mr President, Whatever you want. So now it's just demonstrated. First. If I type my name, it just shows the message. But if I said Washington instead of Show in Washington, says shows, Hello, Mr President. Now, why is that? Because, depending on the value of name either this block off coat. So between those breakfast, some block of coat or this look of code is executed now, in the case of Washington in a variable name is equal to Washington, so it executes this block off coat. If it's any other name, it executes dis block off coast, so it just shows the name. This thing is called an if statement. So, depending on the value of a variable, either this block off code is executed or this look of coat, and it's really a block because I can add more things in here doesn't have to be a single line. That's why we save Lakoff coats. So that could be 50 lines here or hundreds between those brackets as well as here. So this is an if statement 21. Functions: When creating an up, we can divide our coat and functions and function is simply a block of coaches can be repeatedly called. So let's take a console application press. OK, now we have one function here, which is main Can ads. Guns old does risky Now we could add another function. Let's say function. Hello? Which out boots? Hello worlds. Now this is how you would define a function. So always have these brackets. You have to begin off the function in the end, in the code in between. So now we can call the function Hello if you run the codes, See doesn't run because in the case off program needs to be static, which means it's scalable from anywhere in the coach. So you see, it's called once, and you can call it multiple times if you wish. So now I'm going to call it four times and you'll see the function is called each time the code in between his executed. That's why we see four times Hello worlds. Functions can also be can also use variables. So if we type available name in here se Hello name. So we call it like this and you'll see the function is called which the variable you Timmy . So I put step to the screen and we can call it multiple times, which which whatever, whatever para meters you want to use. I'm just calling it three times with different perimeters and know that the variable is used, so name each time contains a different value, depending on how we called it. 22. Functions return variables: functions can also have returned variables. So let me demonstrate it. Let's say you have a variable X, which is, and we use a function called some which doesn't exist yet with 32 values. So we defined a function note we use into, instead off void here, and it returns. Certainly that's he turns, explains why the next plus wise off type inside here So it returns a number if it's voided , returns nothing. So now ex will contain the some off experts. Why? Because when it's called, it's called with Ex history and why is nine? Then it's returns X Plus Y in stores that into X if he would output X. You see, it's the sum of three plus nine so we can do all kind of things inside a function and return the output and use the outputs furthering our coats. In this case, the function dates explains why and returned that and we stored at an X, and we continue to use X 23. Read Text File: in this tutorial will reach its expel goto file new projects. Type your project named you name. It reads sex Foul text reader at some textbooks to show your violin. So go up here. There's a line Multi line said it true. I can resize it going to end a button. The only set of texts read file No. Once the button is clicked, it will set this text textbooks one go here we can go. For example Expects one 0.6 Some text now pressing the button will change the text in its xbox. So if you go here, President button dysfunction is executed in the textbooks Text to set. So there you go. Now we want to get it from a foul so we can low tech from a fell using this line of coat. So have variable text off the type text string which in the function called reads all text which gets all off the text fell data to into the variable text. Now, if you see this red line Millo, hold your control key More can go there, show potential fixes and select using system dot io. So that solves the red line problem now your foul needs to exist. So in my case, this foul doesn't exist. So I'm going to start no pets and type some tics or greater foul with text and it's going to save it. Let's say in documents. So counter name it's example txt and notices Insight, the documents directory. So if I go to documents, you see example txt figures of properties, this is the part to the foul change this to flesh Example txt which is just location off our fell. No, instead of text, I'm going to call it a variable. My text doesn't really matter how you call your variable then instead offsetting it to the string but my text So now the fell data off of the foul example txt will be loaded into the variable my text and we will change the textbooks text which is this book's text will be sets to the content off the variable text which is the fell so just the fell content will be show If you press start, you see these two lines of code will do that. This is the foul we created in No, but earlier and it just loads all off the data into the textbooks 24. Read Text File into Array Combobox: You can also read a text foul, so I have great if our customers txt into a combo books. So let's say I add a button to this screen, the text reads, and when it's rich but on his clicks so But in one click we'll read a foul customers txt, but notice just one variable text and we want to have every line I want to read the fell noticed one look, but this different lines write every line is a new customer. This is a customer. This this distance, so every I need to be split by lines we can tap, not splits and split on New Line and the output. He's an array of lines, right? So for every line could show a message books, so that would simply So. What's going on here is we read the foul customers taxi into the variable text, and we convert this block of text in through lines into individual lines and for every line for each line in lines. We shall be line if you run the program and you see it's empty and depressed street. You see it goes for every line and for every line we want to add debts into the customer list right in this box so we can type combo box customers dots and see which function we can use. Got a lot of things. Hi items at line. Make sure we also clear the Kumble books before running the program. Otherwise, we pressed about in a few times in the list just gets longer and longer. So we have a few lines of code now. And if you run it, remember we have, ah, foul with customers here, customers txt, which will be rats and then add it into the box. So it's empty now. And if he puts rest to see all of the customers are edits into the books. So what's going on is we load a foul into the variable text. We separated into lines we clearly existing combo books and then for every line in the in those lines, we add one item to the Campbell Books 25. Write Text to File: in this example will write data to a fell. We're going to create new projects. Windows forms up and let's say some of customers again. So we'll have, Ah, a button. Some text safe named the butter button safe. When you click it, it will save a line of text to a fellow descends the lines of code you needs. So he needs a stream writer to a system that I owed a stream writer foul. Then his equals two new You fell and you need to specify, uh, the foul name as well. So I specified in between these quotes and might want to pull it in users wherever you want to put it, and then you have the line foul. That right line with rights. Line of Data Priceline to the fell and file is close. So if you run this, never button one button breast safe. And now go to your not to the directory where your fellow saved. In my case, I put it in customers so you'll see data appears there. Now you can write multiple lines. If you will do this, can run it. Seen it. All of them are on a separate line so that's a very basic way. Toe ride data to a foul. Now we can use form input. It's we input into the foul. So, let's say and, uh, label name when a textbooks input and we had another imports, let's say country and this would be a drop down books. So a combo books when you can select the country depending on where the company is selling . Let's go in items and and a bunch of countries. But it's OK. Director is a little bit up, so we have a program with two inputs, so we have combo box one. So let's change there, too. Inputs country and the other one will be called in pools Name. I don't want toe my want to align them. Change the coat so we're going to get the name in the country from the books him put name not text, and the country is includes country text. Now you can write to the fell name. Well, it's the country, so that's how we with varieties form fields to a Fowle. So if you it's just opened the leader existing one, I'm going to run the up type of name and select the country breast safe. I noticed we have customers. Txt again with those values. Now, when we press safe, it looks like nothing happens. So we might want to say file saved. And instead of form one, you might actually want to give it a name on a store customer. You can call it whatever you want. Want to direct us down a little? I noticed those blue lines to align. Okay, so if we run it again, type a different name, select a difference customer are safe, you see? Tells his file Safed. So we actually have some user feedback. And if you open the file again, you see it's replaced the original film. I'm going to rename foul here so because it's quite a confusing name, So let's replace it with my fellow. You can call its customer file of anything more specific. Now, instead of this cryptic line, we can also type. File creates fixed. I noticed that the red line So show fixes again your system io. So this is an alternative way, which you a little bit more readable. If you press start, see it's exactly the same can save foul Safed, and it's created so it has one item. No notice that each time we run the program, it replaces to text. No, Instead of create X, we can do appendix, which adds to the existing fell. So if you run it again type of name, select a country press save close it's and if you open the customers fell again. You see now he didn't replace but a pendant to the existing text. Let witty a pen text function. 26. Menubar: That's great. Another app in this example with the menu bar. So it's going to be a map about movies, but the foul new projects Windows Form application and I'm going to name its movie app and press. OK, see this Form a go on the rides. You see text can change it to movie up. Now you have a lot off options here. I'm going to add some text books. Let's pick, uh, an option Books combo box. Put it in here. You think your name is combo box movie and inside will put a bunch of movies to scroll down to items you see collection, press on the boats on the dots, and you can add some movies inside here. So whatever movies you want, um, you can put any movie in here, right? Might want scroll down to text and a default option? No, if you press run, have very basic up in which you can select a movie. No, it might be a little bit fake, so let's add a label toe had more clarity, but we want to use her to do so. The Texas label one. See label one here, select favorite movie hands Okay, so now we have a very basic up in which we can select a movie doesn't do anything practical , but we have an option Now. We can add a menu bar to this to go to two books and you'll see menu strip rectus onto the form. You'll see a menu option appearing here. You can double click. Chris fell. 10 fell and you can add options. Could at exit. No, you'll see. It's a little bits busy on the screen. So was crawled. Its down of its might want this up a bit like this. If you save the program and when it's see, we have, ah, menu bar on top with one option, and we can select a movie. Now we want to do something when the U suppresses exit, so if we double click on exit, you'll see it creates a function just like button click. Now we can sigh application dots, exits. So this line of code and if you run the program and you go to foul exit if we the program quits. So now we have a man, you are with one option, and you might want to add more options. For example, you could have on option help here and inside help. You could have several, like a registered products. And what else could have corruption of you help, and you could have an option about and so on. So if you run the project now, you see we have lots of options here and also one here as well as the up. So we've got a nap with the menu, and you can add logic just by going to the menu. Hands double click on any off those items, too great a function if you double click on the 1st 1 Register projects show a message. Books saying already registered. So now if we press register projects, his will show that message will go to that function to see shows dead message and so good to have any function toe one of these options. Just double click it and you'll see that's the function and you consigned to code in between. Simply if you go to about we can type codas well, doesn't matter which menu item US press run. See all the options here The prince about It's got called dysfunction in People's register , see difficulty, other function. So just how you can add a simple menu to a program 27. About box: we're going to add in about books. There's now if you press help and about, we'll see, not implemented. Let me just run into showed it. Press help about. We don't see any about books. We just see some missions here, so we're going to add in about box. Go to the C sharp icon on the right with your project name. Where is right mouse button and you'll see this list. Pop up Goto at New Aisam. You see this list and from this list, select about books. Rest yet and you'll see this about books. Just got press safe, you see on top. We can switch between the cold, the about books as well as our program, and we can also do that on the site. So here we have about Books one here and form one here, which is a rep. Can you switch between those by clicking? If you go toe help about double click on it. You'll see that jumps to the code that's executed when you click it and we want to show in about books, which is this one. So I need to create a new one, and we can do that with this line and this line only creates the box. So we also need a line to show it she'll dialogue No. If we run the program, press about, you see our application here. So the movie up version and the copyrights have to go to project and then your project name properties pressed a button assembly information and you can type all the information here . Whatever project he wants can type your version. Maybe it's 11 And so on press, OK, And for a safe, we can close this window. And if you go to start help about you see the information here. So 11 So what? We changed and and see this texts wealthy other. So all of the checks off this exchanged can stop with this button all of a dis changed using project Project properties, assembly information. So that's where you change the about books, information 28. Run External Programs: we can use C Sharp to start other applications. For example, let's make a simple up. I'm going to call it my EPS. Inside, this will have a button and pressing this button will start another app, so I'm going to name it's name the text note bets. Hence double click it to open the coat. You've seen this before, but instead we're going to that process here. So we're going to start a process, and we can just type process start inside the program. Name. Example. No pets notice. Dose that red line again. So with your mouse, it's up. Show fixes and CYP using system diagnostics. Agnostic. So now, if you run the program and you pressed about a no pets, you'll see it starts. No beds. We can add more buttons if you once. So let's say we add a button pains and we can do the same trick. So double click the button process. Start like yourself paints. We have two buttons, which starts in the different programs. Arresting paint. It will start pains, and if you present no better, it starts. Nope, It Sometimes you may need to specify a parts to your program so Maybe this is in C program files and so on. But for general program states, you can just use the program name. 29. Personal Newletter Generator: will make another app in this case in which we generate letters matching generate letters. But sometimes you have these mass emails where you get a letter that supposedly for you, but they are sent in book. Let me demonstrate how it works. Go to found new projects, have a windows for MEP and we're going to name email. That's him. Takes a second or so to great projects. Nan. That said a title for our project and we go to two books to the books Select Combo box for all our customers. So let's go toe items and that our customers in there. So you have all your customers in that lets books He would save it on the run. It's takes a second, but you can see it. See you can select, uh, customer. And now we want to generate a letter based on which customers selected shall we take a textbooks. In this case, we need a big textbook, so take textbooks ends. It's a multi line textbooks because we have a letter consist of multiple lines instead of textbooks. One. Let's call it letterbox. No, save it. If you run it, see, we can select a certain user. We have a text box below now, depending on which you Sorry selected. We want another letter too. Or custom letter to be appear Can This is if the selects has changed, This function is called. We can get the current item, which is the customer, right? If something is selected, it's the customer here. So customer name the value is combo box one text. So let's just show a message. Works to show we have the customer name. This is the code here. If we run it and change the customer, let's say we select Jerry Select It shows Jerry so it gets the textbooks value and shows it . Now we can sit, Take any, for example. Kevin, you'll sound message books. So no, we want a custom leather here in the letter books so we can type letterbox texts and then we can type on leather. So dear. So I had a new line type shell s exploration and you can continue adding so inside glasses to add another line. Don't forget the slash in to create actual new line. So I had another new new line in there, right, whatever letter, and finally end which or with your name and your final message. So now if you run the program, it would still show these measures box so we can remove it or we can change it into a Commons in the Commons Code is not executed. So if he had two slices in front, it's a comment. So this Linus kept. No. If we run the program, I can select a user Simple Jerry, and you'll see it's great sour leather. But the new lines are not shown. I think it's less harsh lesson. So instead of flesh and and windows, she needs less our selection remote yet So there. That's new lines. If you run the program and select whichever customary want, you see a custom leather for each customer. He didn't name changes. Now you might want to add a come on the ends just before the customer name. So let's say we select one and it says Dear James comma And much so, depending on which customers selected, uh, same leather four months used and obviously in the case of anymore, let's and you won't have ah send button, which actually sends the email 30. Image Viewer: Let's make an image viewer So we have a broken that shows an image, and the person that uses the program can change the image so we can open any image using our new program. Goto fell new projects, and it's great our image viewer changed the name to image viewer press. OK, see it lowest. Come to the right to change the title. No, just the window. Tidal change to image. Fewer go to to box picture books and direct the picture books on there. We can resize it and notice there is no image. So on the right. We have image here, express on the small dots. Select import, goto any directory with images and select an image press. OK, no, we can run the program and we'll have a window with an image, but noted the image doesn't fit into the window. So if you click on the image and you scroll down in this list, there is actually an option to to stretch it. It's called size mode and in size mode, Select stretch image. So now the image fits into the books. Press safe, and if you press run, you'll see it loads an image that actually fits into the box. Now it's an image viewer, so it would be make no sense to only show one image. We need to be ableto select an image. So we had them on button and changed the text to juice Image. Make it a little bit larger, and we also named The buttons was crawl up and it's called button one cause choose image button. Now, if we press it, it needs to open a file. Dialog. C sharp actually has a foul day look by default. If you go to to books, you'll see there's an open fell by a look. So direct this on there on the form you'll see disappearing. It is fine. Double click on the image and you can type open filed. I look, she'll die. Look, And if you run the program now you see our image Viewer can press, choose image and a dialog appears. No, it doesn't actually store the founding. So we need to have the foul name, which is over type text us, also known as string and we type opened filed airlock not founding. Now, just to make sure we have to write variable, we talked message boxes show. So have these three lines of coat, all of which ends with a semi colon if we run it and we go to an image on the computer. So let's say this computer see, must be some image in directory whip. Okay, let's say we select this one. It tells us, departs to refer to the image we got our image Street, RJ pack and the parts of it. Answer that. But it doesn't Shane ships, but we sure that the variable fell name contains two actual parts of the image. So instead of showing a message E books, we wanted to appear in the picture books. So in this one, it's called picture Books. One. It's not such a good picture picture name because there is only one book. So why would we name it one? It's going to name it. Picture books and double click on the image will see the code again. So I picture books that image this image nuts from fell fell name like this. So now if we run the coat, select one so that select this one. You see the image changes because we got to found him from the open fouled Outlook stores into the terrible foul name, and we load that we load the image using image that from foul using our foul name, you'll see that we assign it to picture, book, start image we can change it to, so any image, whichever image you want to load. 31. Web browser: Now we'll create a Web browser, a simple Web browser. It's his program to view a webpages to go toe fell new project Windows forms application and type your type of name off your program. It's going to name it Browser Press. OK, first thing we'll do is always change the title, the name, its Web browser and the Web browser usually has, Ah, window to show the webpage in Let's First for That's going to box and you'll see Web browser Here. Directed inside might make this a little bit larger. Can type the euro, for example, Can adds. Google does come in here. If you run the program, Siegel will come appearing might not be strictly necessary to at this in front that's automatically and notice. It's totally full screen Inside. Joke changed that. Change it to none. Then it's not full screen anymore, and we can make it to the size to the desire size. In this case, if we run it, see, it's not totally feeling the window anymore. We got our basic Web browser here without on import fields to open the websites, so let's move this a little bit down and we want to have fields here to type the website because now it always opens google dot com. And it's not always the page you want to visit. No, so let's make it a little bit larger. So that's a whole page. Fits on the Web browser to notice. We can change the website in here. So we're at the books in here. Textbooks for our Bronson. It's a little bit larger and gave it the name. So inside name school textbooks call it website books. No, we'll also had a button about him. Go name It's button, go scroll down to text. And if you use the cursor keys, you can move them up just a pixel or so on down the pixel. No, I'm just moving in on the same lane. You think our psyche up, So if we press go, we want a new pitch to appear. So number click on Go and we type. We get a text, but it's for store the text and we store this text into a variable in the variable off the type text. So this is the way to do it. Now we have Teoh the value off the textbooks, so the value of these books inside the favorable known as websites. Now we want a website to appear inside this books Note. It's called Web browser one. If you go here and we type Web browser one. Those get all kind of options. Yeah. So now we select Weber. Also one. And these books has, ah function felt never Gates. We can call that with any euro. So are you where I was thoughts and website the press start. You can type something in here any any websites. For example, you two meters come fresco and snow. No website the pierce, now the websites control is is a very basic control. So it tells us that we are not using one off the known web browsers because we build it, but we can use it to serve. So if you visit any websites fresco, it will start loading. That webpage can be any weapons you want. So this is the website is how you use the website control and way. We don't have any other controls here, just the books and the go button. But if you want, you can add more buttons. For example, if we make this a little bit smaller stone go to to box button, and we're going toe the back button antics. Bic. The name is Martin one. So changed it to, but Beck. Click on it. You can see where Brosa one nuts go back. I think they also have a foreword. Ones. Yes. So let's say we visit a new weapons. Let's say em ups. So now we have a back button, which goes back to the previous pitch. So just my calling. Weber awesome. One does go back. You can get more buttons if you want, so you can add a for what? One. Select some name. Double click. It's my eyebrows. One. Let's go forwards. We'll have to navigation buttons on your browser, right? You can go back forwards, and you can also visit a page. No notice. You can also add an image to it. If you pressed adults here, press imports collect can select some image on your screen on your computer. I don't think I have any specific images on the computer, but doesn't seem like I have anything. Any image, but you can press open on okay, and you see instead of text and image appearing there. So this is how you built a basic Web browser