C# by Example Crash Course
Key Takeaways
The video 'C# by Example Crash Course' by Hussein Nasser covers the basics of C# programming language, including setup, console interface, file system management, DLLs, and object-oriented concepts, with a practical project of building a Twitter application using C#.
Full Transcript
c-sharp is one of the popular programming languages out there that was designed to write application for Windows operating systems you can use the programming language to write desktop applications you can write console applications you can also write web side application web server applications in this course this is actually guys this is a course that I have done on udemy and I decided to just pull it back and put it on YouTube and I'm gonna hopefully I'm gonna give you just like a quick layout of the course with the timestamps that you can go and jump to the sections that you're interested in and I call the c-sharp by example learn coding by example with c-sharp so this course is absolutely for beginners people who never programmed before this is good for you guys and essentially it's by example because I build up this course using and actually a practical project or exam we're building essentially a Twitter application right using c-sharp yeah there is no web interfaces or anything this is almost like a level 1 course think about it this way so if you want to learn C shop this is a good course for you god so this is the outline of the course eShop by example crash course outline so we're gonna go through all of these sections and you can you should see if I'm a decent editor you should see timestamps here and each one of the sections where you can jump to the section you're interested in you can watch that particular section and there are almost more than 24 lectures and you can you can watch whatever you're interested in essentially okay so we're gonna talk about an introduction why would someone pick C sharp alright again guys I brought this course on maybe two years ago so there might be some information that outdated so I just take take that with a grain of salt section one we're gonna talk about setup what do you need to get a star you need a Windows machine obviously I think you can write C sure code on Mac I didn't go through that with this course but with Matt with Windows you can definitely do that I've gotta go through the details of that section too we're going to about building console interface so how can you write this is one of the projects that you can do in c-sharp where you can essentially build a console application a command-line interface right and essentially here's what the project started the Twitter application starts right we're gonna talk about variables you can talk about alternative things right how do you basically take input from the user how do you write an output and all that thing section and today we're gonna be old about file system management's are you gonna write files to disk in a read file from this no databases or any of the left thing because remember this is a very basic course you can write files and read files we're gonna learn about that you can write the tweets to disk and read it from the disk I kind of like a very primitive Twitter application the single users are mostly section 4 we're gonna introduce DLL the dynamic link library where you can kind of group code into an external library and call that function from an external library instead to make your project more I would say component based if you will and I'm gonna talk about a lot of object-oriented concept in this course as well right we're gonna talk about inheritance polymorphism all that jazz section 5 we're going to build a like a nice interface with this like section I will be building windows form interface with that alright guys that's it let's just jump into their course hey guys thank you so much for checking out this course it means a lot to me so the first question we want to answer here is why you wanna learn c-sharp alright so while I learn programming to begin with programming is the art of having the skills to talk to a device a computer being that being a computer and machine refrigerator or anything that has compute power you have the ability to talk to it and tell it to do stuff for you and that is what inspires me to learn programming and I hope you who have you have your reasons to learn programming basically right so come back to our question why do we want to learn c-sharp right c-sharp is one of the very famous programming languages especially on top of the Windows platform right this was designed by Microsoft on top of the dotnet framework and if you think about it and if you learn c-sharp you have that skill and you can use it in order to build application for this great marketplace correct right so and that being said there are a lot of companies also use the c-sharp and visual basic as their main language development platform so they can build application on top of the Windows platform all right so that's why you want to sell you a c-sharp c-sharp is great language right you can use it and build great applications whether this application could be in the desktop on the back end or or as a small IOT device c-sharp is a great programming language to learn so if you're familiar with my work my books and my courses almost all of them I always teach my example so what does that mean so there are two methods of learning you can learn by learning the individual tools right this is a variable this is an object this is a hammer this is a screwdriver right that's one way of learning the other type of learning is actually to build something to start building something and in the process learn what tools do you need in order to build that thing okay and adds might always be my motto in building anything and learning anything Larry I like to learn by example okay and that brings us to this course and this course is no difference we're going to learn by example and this is what are we going to learn alright guys so what are we building we are building for this course learning c-sharp but in order to learn c-sharp we need an example and that example I have big Twitter we're actually building Twitter from scratch okay we're gonna learn how to build an application that console application the interface how can we post and you tweet how can we read tweets how can we search for tweets and the persistence mechanism of do we persist in memory do we persist it in desk and all these kind of cool things in this course so you're gonna learn by example or step by step as we go through lecture by lecture we're going to add concepts and we're gonna add new functionality to the application as we progress and we're gonna build a good rate application at the end by the end of this course right this is a for absolute beginners obviously you don't have to know a lake of code you don't need to understand c-sharp you don't need to understand any of that right all you need is a Windows machine to get started if you have a Windows machine it's blank right you can get started right now hey guys so in this lecture we will learn how to download the Visual Studio community IDE which is the tool that you're going to use to build the c-sharp application the same tool right or the interactive development environment what can be used to develop in many languages as well so Visual Basic C sharp F sharp C++ JavaScript and HTML typescript even Python right okay but I do recommend if you want to do Python or JavaScript use the slider or version which is the Visual Studio code to do that but that said let's just jump into it okay so for this tool alright or the editor okay this is not actually actually a simple editor action actually allows you to compile your code into a binary which you can execute and distribute and then send to people and even put it in a flash drive and execute right so this is available for both Mac and Windows but in this course I am just gonna completely explain it in the windows because that C sharp is more popular for windows development kinda alright so that's what I recommend doing that so let's just have windows select windows here click on download Visual Studio community that will basically download and we're gonna go ahead and install I'm gonna cut through the part where it is like very obvious things alright so just go ahead and click run okay go ahead yes and today today I'm using Windows 10 for this but feel free to use Windows 8 I think sevens also should be should be supported with that so before you get started you we need to set up a few things that can configure in our installation so you just hit continue and this will take like few more minutes to download all right guys so once that step is done it will ask you now you'll be asked to pick what environments you want to you're interested in developing n alright so there is a lot as we discussed before we are only interested in c-sharp for the scores so don't bother yourself and download all that stuff you don't you're not gonna use it alright so we're interested in the distal development so I'm gonna just because you can do windows form and c-sharp but that's exactly what we're gonna do and that's exactly what you need you don't need anything else right just go ahead and click install that's gonna take a long time maybe it becomes like 3.7 gb depends on on the your internet speed and all that stuff alright again guys we're using the Visual Studio Community Edition which is a pretty completely free you don't have to pay for it right here's where download if you are interested in becoming part of a team or maybe you're currently in an organization where you have to dress to be professional or Enterprise just feel free to do is that right so that will give you more access to other tools within that platform alright guys looks like we are done once this is done it will auto launch your Visual Studio 2017 community all right so let's take a look so it will ask you to log in with your Microsoft account you can skip that you can do it later this is just just make you in sync to get you your private get repository and sourcesafe and all that stuff consider getting an account you don't have to know it's an Outlook account if you have an Outlook I think even hotmail works right any Microsoft account I'm gonna say just not now maybe later we're getting things depends on your preference you want a light environment or dark environment totally up to you I'm gonna use dark start you like the dark mode more so I'm going to go ahead and do store and well we will also adjust the development like phones so you guys you can obviously see the text here while I code all right obviously I can always hopefully know how to zoom right look at that all right so just like I'm gonna do that but just in case I'm gonna make the text more but essentially you guys are ready to code whenever you get that you're ready all right you can just start coding I can move to the next section or the next lecture to start building your application today all right guys see you in the next lecture hey guys in this lecture we'll explain the difference between a solution and a project this is a concept only in this Visual Studio IDE enter integrated development environment alright so in a nutshell if a solution is a collection of projects okay and so this is think of it like you're building your you're a team of a lot of developers and you guys don't want to build multiple pieces of your application so you each one will work on a project but all of you will put the project in a single solution so that's one way to do it so let's go ahead and just run Visual Studio 2017 you can run it this way or just search for it Visual Studio alright so if I go ahead and create like a new project you would get this concept of what different types of project that you can create and this is pretty cool right so this is there are different languages a project can be a person can be a single language you cannot next match project right so the project could be like a c-sharp console application we can explain all that don't worry about it alright class library a Windows forum right and or a visual basic project right but all of them can if you want to be in the same solution and in this course we're gonna do exactly that we're gonna build one solution okay and we gotta start building different projects and add it to this solution and that's the beauty of of essentially reusing your code where you can build the code do something with it and just like have P some other people contribute to your project and so on alright guys so that's as I'm sure the difference like that means you actually just creates a simple project so I'm gonna call this console application console project but the solution name I'm gonna call it my team solution okay so if I do that make sure to always check that create directory for solution all right so when you do that you will get you'll get the solutions created and the project create and this case I created a c-sharp console application alright alright guys so once your project is created you'll see this exactly right so you'll see a project and you see the solution you can install renamed add if you want to by the beauty of this you can start now right - clicking on this and you can add even an existing project or a new project so let's go ahead and just show you can I can add a project of a different completely different programming language let's say a form project let's say my form project alright and then you can start building multiple projects right so although these are this is a VB project bejeweled basically this is C sharp I was able to add those to a project in my solution and then you can choose to build all that don't worry about it guys I'm gonna explain all about it but that's the essential concept of a difference between a solution and a project if you saw that in your system right so just like to understand what Sarah what's the difference between that you all right guys we're gonna get ahead to the next lecture where we actually build a real-life project and a solution and start building and adding code to it alright guys see you in the next lecture bye alright guys we are ready to build our twitter application right so as we discussed before right so this course we're gonna build something we're going to build this Twitter application we try to attempt to build a square application and in the process we're going to learn the tools and the different concept programming concept when we need it and we'll start applying it to the application and it's to the other way around where you will learn concepts and tools and then try to kind of Lego break it and then build something out of it right I always believe that we should build it as an example alright so that's why we exactly what a bit we're gonna build right so we're gonna build a Twitter console application alright so this is an application where you can actually write tweet and read tweets and do some cool stuff with that alright alright guys let's start with that alright so we're gonna head to open our visual studio code and head to file and then new then you'll hit project ok once you click project we will make sure to go to visual C sharp that's where recording against try this that's our programming language for this course and click on c-sharp and then click on console application ok for the name of the project as we explained before there are two things there are the name of the project and the solution if you create a new project you always are asked for the name of the solution as well so the solution is the collection of project ok and that's our solution let's start with the solution name so the solution name will be I'm gonna call this C C sharp Twitter let's call this project right that's kind of confusing to call this project say to our application okay make sense that the whole thing but this particular project is called Twitter console okay make sense guys let's go ahead and we have the name of the protest where console and the c-sharp Twitter application is the entire solution and then make sure to check this box create directory or solution because we want this the whole thing to fit in a directory okay and then we're ready wait click and that will create our console application you know we're gonna go ahead and save it we did not specify the where do you want to put that solution but I guess whatever we put it is as good I think right so where did we put that it was and it was created and under C user source repos and then there is a project there obviously you can always change the location of where you want to put your code okay guys just like that we have we are ready to start coding let's head to the next lecture let's go ahead and say it first our project obviously we didn't do anything but saving is good right so for this section we'll start building out this application we're going to explain everything you see on this screen here guys so I don't don't get intimidated by a lot of coding here it's just like very basic things right whenever we need something we're gonna build it alright guys see you in the next lecture bye hey guys we are ready to write our first code alright so if you accidentally close the project don't worry we can always open it again so go ahead and just look for Visual Studio 2017 then once you open that you should see it on the recent but don't worry if you don't you go ahead and just go open solution and then look for it under your the folder that you saved it in alright usually it's gonna be in the location there so go ahead and open the solution you always want to open the solution guys don't open the project along because hoping the solution will open all its project as well okay in this lecture we're gonna write the first code that will allow us to view a tweet though let's assume we have a bunch of tweets alright and we're gonna view them I go for this lecture we have one single to you and we just want to show it on the on the screen alright and they own the console application here which is this black thing you see and a command prompt here right so that's the console essentially alright so let's start alright so we will start by writing all our code in this little main we're gonna call it method okay so all your code who goes between these two bragg braces okay so this is the start and this is the end and your code will start here and a tweet is as a collection of characters correct alright and this collection of character is called a string so and that string you can declare it and save it into what we call a variable okay so I'm gonna go ahead and declare a variable call it tweet okay and then I'm gonna save in that tweet a value of let's say hey this is my first tweet okay c-sharp when you write code you have to end that code with a semicolon there are cases that you do not have to but we're gonna explain that but just like that when you write what the first line of code that you wrote is will take that is our tweet and then take that collection of characters the letter edge e comma space and all that stuff which we call system dot string and store it in this handler when we call a variable a local variable we gonna persist that result in this variable and this is an in-memory thing so this will happen as long as the application is running this is gonna be storing this applique this variable once the application is destroyed or closed this is all gonna go recycled to the operating system okay so by doing that you notice that there's like a little green dashed line here saying that hey you declared a variable but you and you assigned it a value but you never used it okay don't worry Visual Studio code we're gonna use it just for an hour now in a minute so what I'm gonna write here is the the second line of code is dot has to be capital right because C sharp is a case sensitive language so we need to council the right line you do a space has to be capital W capital L then you open parenthesis and you say what do you want to write in the console okay so by doing that I want to write my tweet that I just draw and just like we explained c-sharp have to end with a semicolon all right all right so now we're ready to build and run our application to do that we will simply hit this start button okay this is what this will run and debug mode to tell us if we made a mistake or we did something wrong okay so by running that it will run the application and if you noticed the application immediately closes we didn't get to see our work okay and the because we didn't tell the application to stop all right or to pose to do that we need an other line of code called read line okay and what that does is it will ask the user and will ask us to UM put something so to is it waits for us to UM put something before it closes okay once the code reaches here the application is done and we'll be closing okay so if we add a semicolon here and then we run the application we notice that I can see hey this is my first tweet so we just view viewed while we're tweet here that is already existing think of it like oh it's already there I'm gonna view it we're gonna build more more cool cool stuff guys all right all right and then just by closing it this way or I hit enter the application is done so let me show you a little bit of debugging if I clicked here now and then this will create a breaking point which will allow us to step into the code line by line and will allow us to see what is going on and this is very powerful so let's go ahead and just step in the line and then sees okay I mean um the code is still in your head by the way I'm executing this code they highlighted the other ones they say I'm executing this one and to move on you essentially just say step in to just like go to the next one okay and the next line is go and take that variable and write it to the screen so it's cool that if you if you hover over you can actually see the value of their variable right just go ahead and do that and then that will obviously print that and then if you do this well it will sit there and wait unless we type something once we type something and hit enter this will go to the next line which is this and if I do this the application will be closed alright guys so this was a very simple way of writing and viewing the tweet that we just wrote okay guys we're going to move to the next lecture where we do more slightly more interesting stuff stay tuned hey guys so far what we did is we took an existing text and we viewed it as a tweet right so we viewed a tweet from the application but we didn't get to write our own tweet and and and store it there so in this lecture we're gonna know learn how to take a post a tweet to the application and store it in memory okay guys let's start with that okay so there is a single variable that calls tweet and there is this sticks alright so I'm gonna go ahead and remove that okay so I'm gonna remove that whole entire entire thing and instead I'm gonna say string tweet I'm gonna declare the variable called tweet which is the same thing but instead of having a string in the application I am going to use consul dude you have already learned this guy's called read line so read line I lied it does two things doesn't only allow you just to write on it it actually takes your input and guess what it it takes your input and the highlighted part becomes that string that we talked about right and then gets persisted into this tweet I shouldn't use the word persistent but yeah stored and this variable that is called tweet and it's like think of this as like a box that contains value that is just floating in your computer memory until the application is closed okay and then once application is closed that variables go don't okay so this will take this tweet all right and then we'll store it in the tweet variable then it will write write it back to us and then will again ask us to write something but we know we're not gonna do anything with it we're just gonna throw it out whatever we ask us this is just to stop the application from closing let's go ahead and start and see what will happen so if you notice this time if I had run the application ed well just keep blinking right well just like it's like it's waiting for us it's kind of weird but it's actually doing something it's waiting for you so this is okay this is saying my second to eat actually and then dot and then you hit enter and then you get the exact same text back which is the tweet all right so you just essentially posted that waste and then we're still waiting and then when you hit okay replication is done so we need some other kind of labels that tells you what's going on right so before we ask the user ask us to put that tweet we can write something right we can ask him to write hey enter tweet to post then you can do this then so if you know this code this time I didn't use a variable nothing stopping if you're doing that you can do it if you want you can't put a variable called inter tweet to post and the space and then you can do that and let's actually do that right see inter to it to post and then the read line will be waiting for you to enter so this this makes more sense now right okay oh oh you want me to enter it a tweet okay I look like this this is might wait and then do that okay there you go we can now also do more cool things like hey how about after writing the tweet say console dot write line tweet posted successfully and then we can we can write console right right your tweet I am going to use if you notice that the first one I used accidentally was right not right line so the only difference is right will not write a line after it it will it will not like I have as if you're writing in notepad right let's go to note and show you so if you like if you're writing something here writes it's like enter tweet to post if I did write line then it will physically put a line there so the next top text will go after that if you do if you just say right it will not write a new line and sometimes you want to do that sometimes you don't so let's do right here because I want to show your tweet is and then we'll just print it tweet after that immediately all right let's see what will happen when I run this code now okay so I'm gonna go ahead and just zoom in for you guys a little bit here saying no sir tweets or get prompted and then I'm gonna write my tweet and it says tweet posted successfully and then your tweet is for say announcer at 1:00 and whatever you write all right guys I'm gonna stop here and that feel free to play with this application feel free able to play with the code and I'm gonna see you in the next lecture where we're gonna do more cooler stuff see you there hey guys in this lecture we will show how to display the length of this tweet and this is for a very good reason remember Garth tweet can only be 140 characters we're gonna come to that day a later lecture but for now we just want to display that how can we know the length of a tweet that's very very very simple and very good question as well alright so a tweet variable here and especially if it's a string if it's just string there is a property right in this string that he can do called tweet dot length and guess what it gives you it gives you the link the number of characters consumed then the number of characters and the current string object right so actually tells us the length of that string yeah so how can we do that there are multiple ways let's do that console the right line I just like actually just write mine yeah write your tweet length is or just like and your tweet length is and you can do that then we close that oh don't forget your semicolons whenever you see that red that means something is wrong then we there console the right line and then we do tweet the length it has to be capital all right guys let's try that see if it works okay and my twitter is saying now sir is cool I can't believe it doing myself all right this is tweet okay your tweet is then also school this is this is his tweet your tweet length is 41 all right let's try something else you guys Rock it's 14 characters alright nice what I want to do here is actually he's 32 know like the color style it's like to become really difficult to read isn't it so we're gonna do is show you a cool tool yeah right only when you need it when you start wanna start things getting around and again if this is comfortable for you continue using it you don't have to use the new things that I'm gonna give you right you don't have at all okay whatever works for you works alright guys so what I'm gonna tell you here is is I'm gonna remove all this code now okay and I'm gonna remove all this good I'm gonna say console the right line I'm gonna do it in one line try at least okay the way I'll do it is your tweet is and then I'm gonna use this special character called curly braces and I'm gonna give it a number zero okay this is the first variable okay and the next is just a bunch of strings that we and characters that we're gonna print on the screen and comma and you don't have to put the comma was just optional and it's length is guess what variable number one okay what what what does that mean though okay it means that after you finish your strength you put a comma there and this console the ride will take the list of variables consequently okay so the first variable which is number zero goes to the tweet right I want the tweet to go there and the second variable which is number one I want the tweet dot length the length of the tweet and obviously I need to put a semicolon there right so this becomes really hard to read you can do this I think think yeah it doesn't complain right does it it doesn't complain that's good I think you can't even do that alright I think this is just slightly more readable if you will right so just go ahead and start and you should get okay enter your tweet to post hi this is my third tweet okay your tweet is hi this is my third tweet and it's length is 27 okay so looks cool alright we can really well to just to identify that tweet you can just add it between single codes right let's try it again this is my third tweet you know what that's what I mean right your tweet is now between the single code and it's Lincoln's 24 make sense guys all right see you on the next lecture with more cooler stuff hello guys in this lecture we will learn how to view actually post and view multiple tweets and the first thought that you might occur to you is like well just use multiple variables and that's exactly what we're gonna do right so let's do that okay for simplicity let's let's say I'm gonna create five tweets oh it's for for tweets okay so I'm gonna say tweet number one intertweet number one okay enter tweet number one alright then we read tweet number one and then maybe just copy and paste copy and paste copy and paste intertweet number two it's complaining because the variable already exists obviously this is number two tweet number to tweet number three tweet number three and tweet number four so we have successfully read from the user for tweets now we need to turn around and write them okay so let's get tweets posted successfully alright and then just for fun I'm gonna add another line of code yes this is how you do just an empty line okay and I'm gonna remove that we don't need it right now okay so now how do I actually print those tweets well sounds simple right console the right line your tweets or like that just name right actually then guess what console the right line to each one there are multiple ways of doing this right guys so you can do it this way tweet one two three and four and you can start noticing something that is getting repetitive and that is the point of this lecture okay let's go ahead and run this so that's cuss tweet number one this is my first wait there she's more she can't wait this is my third weight and I can't write this is my fourth tweet and that's just for fun domain hold it here okay tweet posted successfully your tweets are this is my first tweet this is my second tweet this is my third tweet this is my father and you know guys like white what this happened that's that's easy because we didn't do a new line I mean this is simple if we do like this is a feed in this as a new line then well they will print all of that okay there is a better way of doing this and and this will moves us to that topic this is the notice to the tool that we need there's a tool that we actually need here to remove ugly code like that repetitive code essentially right you know repetitive code is fine again it's okay but it can become really cumbersome if you're surprising a lot of application you know what colon repeats itself right because if you want to change something you have to go and change it in all places right you want things to be simple okay and that's what we're gonna do here okay so let's start introducing arrays that's the first tool we're gonna need okay so I'm gonna create an array of string and array think of it it's like a conceit consecutive chain a big chain of the same variable type okay and that's in c-sharp and different languages could be different but that's actually essentially it's like a sequence or thing it has an index right and then once it has this index each index bugsy index position number zero have this variable position number two have this variable okay all right guys so in this in this lecture we're gonna describe how to build an array okay and to build an array there are many ways to build an array think of an array is like it's a collection a chain of variables said consequently together that's that's one array is and the beauty of an array is because of this chain it allows - actually this this pattern will do it allow us to do really cool things that we're gonna explain in the coming minute or so alright so let's go ahead and declare on alright this is how we declare it's very simple okay you declare that you've started with a type of this array what what content what's the type of this array and you can say it listen I want an array of string because all a bunch of tweets right so this was a real trade then I'm gonna call it tweets and then you're gonna initialize that error you have to do that what content what what what will be in the array how what's the size of the array you have to put this in the C shop in JavaScript Python you don't really have to do that but in C job you have to do that okay so to do that we you actually new string and then you just put the number okay and in this case it's four okay then you've put a semicolon okay so now I created an array an empty array of four slots for variables so what will will this give me so now if I start replacing that code right there our variables with the individual arrays this is what I'm gonna get right we don't need to declare them anymore so we get do tweets sub 0 which is the first element the first array the first variable of the array okay use that and then the second one will be guess what sub one that's correct and then the third one will be sub-2 and sub-3 and that's it so now we filled those so if you think about this is an array of four but the maximum element is three so don't get this confuses it confuses you right because arrays always start from zero and then programming okay so that I will essentially store the variables in tweet zero one two three all right and then we're going to turn around and print those tweets Sub Zero tweet sub one and tweets stop - and then tweets sub three and then now P we're gonna have questions right it's like what did you actually did it's like you didn't do anything he just like me made it actually harder because like you still lose the variable might as well just use the variable why did you introduce this alright just a second we're gonna get to it guys we're gonna get to it all right let's make sure this works first okay I run this and I say hey my first wait my second tweet my fear tweet my fourth last tweet okay and it looks like it's working alright it is working but this is not what we use arrays the reason we introduce a race is to get rid of most of this code and that is that brings us to the next tool that we need to make our code looks better all right and that tool is loops but that will be in the next episode stay tuned hey guys so in the previous lecture we have introduced arrays and we learn about arrays and part two of that lecture because it's a very long lecture so we had to put split in two and this this lecture we're gonna introduce loops and how we can combine loops an array to build really cool things and really concise and efficient programming so we're gonna introduce loops loops is a very interesting programming concept it's mandatory into programming you gotta do loops right because if you see things that repetitive like that it's repeating right you want to use a loop and change something and this loop that will kind of iterate on that code over and over again okay and to do that we're gonna do we're gonna replace all this code if you notice right because all the SCOTUS is exactly the same so what I were gonna do is I'm gonna comment out all this code and commenting out is actually a pretty cool thing as well and this is in order to say hey I want the code but I don't want it deleted I want to just comment it out so I can just the the compiler in our case will ignore it but it's there for us does that make sense guys right this is like you can write things like oh this is my array you can try pretty much anything you want and the compiler ignore it so it won't actually check it okay so the next thing I want to do is actually do an array so a loop so we're gonna do a for loop for integer because integer is a number okay I'm gonna start a variable and integer from zero okay while I is less than that tweets dot length remember we did that before right but always for a string array has the same property called length okay which is essentially for right you might ask is like okay why did why didn't you just type for it's better to not repeat things that is obvious if you know it's for then use that same barrier because if you change it it will it will just use the latest value you do without how you having to change the code every time does that make sense guys so I list then while I is less than four go ahead and do I plus plus so I plus plus means literally increase I by one okay and then it's open a braces here including and indicating this is our code remember this is exactly like this braces braces means that this is my braces of code and I'm gonna execute this loop and this in this actually initially between these braces okay I'm gonna copy just this part and I paste it here what that means is loop start with zero okay check the second step is check is zero less than four yeah zeroes the sample what do you want me to do okay if it's true continue and do this code okay let's not look at the call right now but now move to the next and now once you execute the code this will actually not terminate it will go back and execute this okay which will increase the I by one which makes it one and then you check again right is one less than four yes execute the code reach here and then go here again which increments the I by one which makes it two two lists two is still less than four continue executing three still less than four execute four for less than four ah no so once this condition is broken go ahead and exit and that's when we know that loop is broken okay what that said now that I have I okay I can what is the value that keep changes with okay zero here should be I isn't it right because tweed sub-zero then tweets up one then tweet sub one to until it reaches three and that's that will be done okay and let's keep this one for an outfit so we don't get confused okay and then this is code will be ignored okay can actually safely just remove it don't really care and let's keep this as well okay still we can improve this better again yeah you might you might actually know already know how to do that let's go do that my first tweet second tweet third tweet last week if you notice it still says one right but if I do that now it works right my first tweet my second tweet is it actually printed all of them and with with less lines of code right now it says like it says more readable it's a loop right now how do I remove this one and then you replace it with an actual tweet number blah right tweet number get what zero remember we did that in the previous lecture and the parameter is actually I okay let's see what will happen if I run it again I'm gonna get my first tweet you notice this is number zero okay but that makes sense right because the first zero and then second tweet 34 and that I work zero one two three obviously human don't deal with zeros right at the first one so how do you start from one as just displaying to the user do you guess that just that plus one and that does the trick right now if you notice it will start from one alright make sense guys alright so let's go and finish the last thing which is this tweet I'm gonna replace this four lines with a loop how do we do it we can still reuse the I variable there okay so while I is less than tweets dot length I plus plus and I'm going to do council the right line okay your tweet is or just like we can just like your tweet number which would be fancier no is one we did all that stuff got right guys so this will be I plus 1 and this will be to eat sub I that makes sense guys right let's just add this here so it's room more readable okay so the first variable will go to this the second one will take the I've element of the tweet okay and that will basically start increment in one two or three four and that's what that's the cool part of this right I'm gonna start looping through this okay that's this tower code tweet my first boy second my third fourth slashed okay and looks like it's working guys alright so we just introduced our raise we do introduce loops in the context of actually building an application right so in that process we're gonna build in the next lecture we're gonna build more and more coolish stuff i think with these these are the most I would say the hardest thing to learn and once you give these you're good to go you're good to go and there's just like you're ready to build application school applications guys all right I'm gonna see you in the next one guys stay awesome hey guys in this lecture we will learn that very important tool that you can use in your entire programming and social engineering career we're going to learn about the condition statement alright and the if statement okay so we're going to learn it in the context of our applications that we're building which is Twitter okay so as you all know with Twitter there is a very important condition that you cannot write a tweet that is longer than 140 characters correct and we're gonna use that same condition to actually restrict tweets that are longer than 140 and only allow tweets that are 140 characters or less let's get to it okay so there are two ways of there are many ways to do this here okay we can restrict it while reading it from the user because this is where we're we're rewriting the tweets right we can do it this way or we can also while displaying it hiding that tweets that are longer than 140 characters so for simplicity we're gonna do that just the former the latter one okay so while looping and displaying these tweets I want to put a condition here inside this loop okay if the tweet is greater than 140 characters I'm not gonna display it okay so let's get to it okay the first thing I want to do is that's the current tweet that we're currently I to rating correct so what I want to do is I'm gonna add an if statement and the every statement always are followed by parentheses and inside the parentheses is the logic that you want to check the condition and then you ask you still yourself a question if this is true then do this else dude do something else so let's get to it so it's very simple right if the tweet that I'm currently being against is greater than 140 characters then I do not want to print that or maybe I'm gonna print something like that right right line tweet is longer than 140 characters all right now we get we follow it up with a with a semicolon cool if you hope we have missed a very important thing a tweet by itself is a string it's a text right so we need something that is a number what's how what what tells us what's the length of a tweet remember it's dot length right so that's why that's why that was the error that we got earlier okay if the tweet is longer than 140 I'm gonna print that else I want to print this instead okay and this tells me that this if statement will get executed if that's true we're gonna do that else I'm gonna do that all right so let's check that how about that guys and then I am going to put a very long tweet here I think this is more longer than 140 right and then I'm gonna put something Oh 4 + 4 + 4 you noticed the first tweet we got an error tweet is longer than 140 characters but the rest of them we've printed them nicely with this powerful tool we are ready to move to the next lectures and use it all over we're gonna build a menu and then hopefully in the future lectures we're gonna build an interface this is a very important tool guys we're gonna use it a lot alright see you in the next lecture guys hey guys in this lecture we will learn how to build an interface for our Twitter little application that we have built so far ok and this interface is like this is well unusual right you don't really see such interface here but this is just for the sake of the example ok so the interface will be some sort of a menu right where you will prompt it with it with the console application and you'll pick a number one means post a new tweet to essentially view all existing to it very simple and three will be exit the application alright so to do that I want to start from scratch and I'm gonna go ahead and just delete all this code maybe yeah let's just go ahead and and and then comment out all this code and to comment out all the code you can do this in c-sharp you can do this then you close it out by doing that so you still have the code but it no longer execute so if you do this the application will immediately just start the code and that will immediately close up so yeah as you as you saw right so I don't know what I want to do is I want to introduce the main menu and to do the main menu it's it's very really simple right all we have to do is just really write the truly main menu now we can be fancy like that I can add few dashes indicating that this is the main menu and what I want to do is I want to give users options right so I'm gonna add a brand new line and then let's say option number one view all tweets ok and console dot write line option number two will be forced to new to it about that ok I really need it Dewey okay and console.writeline option number three exit okay if you type that means a few type one okay we're going to view all the tweets - we're going to post a new tweet and three exists application okay so as you can see there is the condition that we have here F then F then F then we're gonna do something like that okay so obviously after we get that we need to ask the user enter your choice right and that will be read line okay go ahead and just read the value of what the user choice will be right and that choice will be literally we're gonna store it in a choice variable called choice sounds good okay so now I will simply for simplicity I will just print back that choice okay you entered choice sounds good sounds good guys and that's that obviously you don't forget at the end of the location because we just want to see the actual menu before it closes so just go ahead and it looks good view all twit number one post new to it number two and three so one you entered one and then the application will exit but what I don't want to do here is I don't know this to exit right I want this to be always looping this meaning is always looping until the user actually clicked three entered three in order to exit the application okay in order to do that we will need to introduce a new kind of right something that we actually never introduced before and this is called the do-while so du is a loop that is introduced right it's a loop that has optional if you want this curly braces that means all the code inside it will immediately execute right and then after that we're gonna do a while and that while is the actual condition okay so the first time we go through this loop we're gonna execute all that we're gonna read ask the user for a choice okay and we will loop as long as the choice is not equal three make sense that's what we want to do okay and if you notice there's a little problem here says hmm choice does not exist in the current context we're going to explain more about it but the solution to this is because that loop doesn't understand what this variable is so we needed to move this up before the do so it actually understand it okay and all we do is we don't need to define it anymore we just use that variable these are is called scope we're gonna talk about scope hopefully in the coming lectures all right so now we got all that and obviously don't forget our semicolon and we're good to go let's try that so now if I enter one I will get back to the loop right if I enter to find literally anything actually I will always go back and print these options if you notice until I print three at that time we actually exit the application all right so that is what I wanted to do today all right just showing you the menu is showing you the if statement we're gonna we're gonna do more and more of statements here in the coming lecture alright so we're gonna just break this left turn into two parts so the menu we introduce a new loop alright and we're just showing you like how can we have a
Original Description
Coding is the skill by which you can have a way to talk to computers and make them do anything you want. You can write code for many devices. Range from computers like desktop and laptops to smartphones to everyday appliances such as fridges.
C# is a very popular language for Windows operating system. More than 80% of desktop computers and devices out there use Windows, this makes learning C# a very appealing choice. Plus most companies use Windows and writing C# Windows apps natively will give you an edge. If you have a computer running Windows you can write a C# desktop application.
In all my books and courses I always teach by example instead of by tools. We set to build an application and during the process of building the application we start using tools.
//What you will learn?
Build a real-life powerful desktop applications with C#
Learn and build applications and apply them in real-life scenarios and context
Object Oriented Programming Best Practices
//Are there any course requirements or prerequisites?
No programming experience is required
All tools are free to download and will be provided in the course
Microsoft Windows Operating System
//Who is course for?
Anyone interesting in .NET technology, building Desktop applications or back end services with C#
Programmers from other background who interested in building applications with C#
//What are we building?
In this course we will be writing a twitter application, we will start with building the small building blocks and introduce new tools along the way. By the end of the course you will have a fully functional twitter application that you can write and view tweets from. It is going to be fun.
Tools you will learn in this course:
1. Variables, Arrays and Loops
2. Classes and Objects
3. Object oriented best practices
4. Code Inheritance
5. Building Dynamic Link Library Projects
6. Reuse objects and classes from DLL
7. Building Forms and Console UX
8. Best practices to separate code from us
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Hussein Nasser · Hussein Nasser · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Extending ArcObjects (IGeometry) - 01 - Getting Started
Hussein Nasser
Extending ArcObjects (IGeometry) - 02 - The Document, The Map and The Layers
Hussein Nasser
Channel Update - New Book, New Job, New Videos
Hussein Nasser
Learn Programming with VB.NET - 01 - Getting Started
Hussein Nasser
Learn Programming with VB.NET - 02 - Classes and Objects (Part 1)
Hussein Nasser
Learn Programming with VB.NET - 03 - Classes and Objects (Part 2)
Hussein Nasser
Learn Programming with VB.NET - 04 - User Interface
Hussein Nasser
Learn Programming with VB.NET - 05 - By Value v. By Reference
Hussein Nasser
Learn Programming with VB.NET - 06 - Variable size, 32 bit vs 64 bit
Hussein Nasser
Learn Programming with VB.NET - 07 - Conditional Statements
Hussein Nasser
Learn Programming with VB.NET - 08 - Inheritance
Hussein Nasser
Learn Programming with VB.NET - 09 - Strategy Design Pattern
Hussein Nasser
Learn Programming with VB.NET - 10 - How did I learn programming
Hussein Nasser
IGeometry 2016 Retrospective - Channel Update
Hussein Nasser
Javascript by Example - The Vook
Hussein Nasser
Vlog - Keep your servers close and your database closer
Hussein Nasser
Vlog - Client/Server Programming Languages
Hussein Nasser
Javascript By Example L1E01 - Getting Started
Hussein Nasser
Persistent Connections (Pros and Cons)
Hussein Nasser
Javascript By Example L1E02 - Building the Calculator Interface
Hussein Nasser
Happy new Year from IGeometry!
Hussein Nasser
Synchronous v. Asynchronous
Hussein Nasser
Javascript By Example L1E03 - Displaying the Digits on Calculator Screen
Hussein Nasser
Show Your Work. Blog, Vlog, Write, Create and Develop!
Hussein Nasser
Relational Database Atomicity Explained By Example
Hussein Nasser
Javascript By Example L1E04 - Operators, All Clear with Arrow Functions
Hussein Nasser
What Comes First, User Experience or Software Architecture?
Hussein Nasser
Javascript By Example L1E05 - Evaluate the Calculator Expressions with eval
Hussein Nasser
Fastest Way to Learn Programming Language or Technology
Hussein Nasser
Javascript By Example L1E06 - Fix Leading Zero Bug with Conditions
Hussein Nasser
Stateful vs Stateless Applications (Explained by Example)
Hussein Nasser
Javascript By Example L1E07 - Running our Calculator on the Mobile Phone
Hussein Nasser
Advice for New Software Engineers and Developers
Hussein Nasser
Why JSON is so Popular?
Hussein Nasser
Building Scalable Software - SLA, HS, VS
Hussein Nasser
Vlog (Istanbul) - Datacenter Proximity
Hussein Nasser
Should Software Engineers Learn Bleeding-Edge Technologies?
Hussein Nasser
Do Developers Build Bad User Interfaces/Experience?
Hussein Nasser
Learn By Doing.
Hussein Nasser
I Wrote Bad Front-End Code That Broke Chrome
Hussein Nasser
My Story
Hussein Nasser
Vlog - Horizontal vs Vertical Scaling
Hussein Nasser
Can User Experience Help Build Better Rest API?
Hussein Nasser
Reverse engineering Instagram in flight mode
Hussein Nasser
The Benefits of the 3-Tier Architecture (e.g. REST API)
Hussein Nasser
Stateless v. Stateful Architecture (Podcast)
Hussein Nasser
The evolution from virtual machines to containers
Hussein Nasser
Proxy vs. Reverse Proxy (Explained by Example)
Hussein Nasser
Canary Deployment (Explained by Example)
Hussein Nasser
No Excuses
Hussein Nasser
Synchronous vs Asynchronous Applications (Explained by Example)
Hussein Nasser
What is an Asynchronous service?
Hussein Nasser
Difference between Client Polling vs Server Push in Notifications
Hussein Nasser
Software vs. Hardware AdBlockers (Explained by Example)
Hussein Nasser
HTTP Caching with E-Tags - (Explained by Example)
Hussein Nasser
Simple Object Access Protocol Pros and Cons (Explained by Example)
Hussein Nasser
Nodejs Express "Hello, World"
Hussein Nasser
Reverse Engineering Instagram feed
Hussein Nasser
Popup Modal Dialog with Javascript and HTML
Hussein Nasser
MIME and Media Type sniffing explained and the type of attacks it leads to
Hussein Nasser
More on: LLM Foundations
View skill →
🎓
Tutor Explanation
DeepCamp AI