If you want to learn how to program, but don’t know where to start this video should help point you in the right direction, the mother programming can be a large and confusing place but let’s try and break it down I find that lots of people who have never tried to program before think of it as one skill being a programmer means how to do one thing however the truth is pretty far from that there are many different programming languages and ways to program so this brings us, to the first decision an aspiring programmer has to make what language do I start with and the answer is well it depends there are a lot of languages to choose from and each have their own strengths and weaknesses.
But most importantly what language is right for you is going to completely depend on what you want to make for this series I’ve chosen to go with c-sharp no not that c-sharp this c-sharp now some of you might know that I’m a bit biased here after all our entire YouTube channel is built around game development and the most public game into today unity uses c-sharp as its programming language but I do believe that c-sharp is a great starting point for most developers this is not because it does everything perfectly no language does but because of its diversity you see c-sharp is a widely used programming language it can be used to develop for mobile PC Mac and even the web and if you want to get into game development you can get started with unity right away it’s also based on C which makes it really similar to other popular languages like C C++ and Java so if you ladies want to pick up another.
Programming language chances are that the transition won’t be too difficult so in this short series you will learn how to get started programming in c-sharp and make your first programs the videos are going to focus on the absolute basics so whether you want to make video games or web apps you should be able to apply everything right away but before we get coding this video is sponsored by Jason Wyman sometimes when learning new skills like coding it can be hard to find the motivation to learn by yourself in this case joining a course alongside other students and with live help from a teacher can be a better choice Jason has made an awesome course on game architecture which will teach you how to write clean and proper game code you’ll have access to live help from Jason himself and a discord channel where you can chat with your fellow students this will also give you access to the game dev mastery course which will teach you how to a variety of game types in unity so make your first game by signing up now simply click the link in the description now once we’ve chosen the language we want to write in.
We need to pick a code editor many modern code editors will not only allow us to write code but also help with debugging and building our program you’ll see some of these referred to as an IDE or integrated development environment but don’t let that scary title throw you off of course there are a lot of code editors to choose from and most of the time it’s a matter of personal preference in this series we’re going to be using Visual Studio code vs code is Microsoft’s lightweight code editor it’s great because it can be used to program in almost any language it’s multi-platform open source and it’s 100% free now.
In this series we’re going to be creating a console application if you don’t know what that is here’s one I agree with you that it does not look very appealing but it’s great for learning how to program since it allows us to focus on the language itself without too many distractions but creating any kind of software completely from scratch is a huge challenge instead we normally use what is called a framework.
For now you can think of a framework like a toolbox with a bunch of tools inside that will help you accomplish your job better and faster it’s kind of the foundation that we build our program on top of we’re going to use the dotnet framework this is also created by Microsoft and it can be used to create pretty much any kind of application so don’t worry you don’t need to understand exactly what a framework is just know that, we need one for now and with that explanation in mind let’s get dotnet and vyas code set up and run our first program get it I ran a program so the first thing that we want to do is install the.net core I’ll of course have a link to this in the description simply follow that link select your platform and hit install then simply follow the installation instructions that you see on this screen it should be pretty straightforward
Once you’re done we can simply hit close and next up we want to install Visual Studio code again now of course have a link for this in the description simply download and follow the installation screen and once it’s done we can go ahead and open up visual studio code now this code by default is really lightweight and it doesn’t have the necessary tools for us to start writing in c-sharp instead we need to install this as an extension so let’s go to the bottom icon in the left hand side and hearing go ahead and search for a c-sharp.
Let’s like the first one as weensy c-sharp by microsoft and that’s emily go ahead and hit install and once it’s finished we are ready to start writing c-sharp however there are actually a lot of really cool extensions available here one that I personally like is the vs code icons so I’m going to search for icons here and select the vs code icons and install it it then prompts me to select it as an icon theme here which I’m gonna do you can also hit this button right here and all this does is just add some nice user friendly icons to all of our files and with that we can go ahead and close down this page and go to the top icon here and we are now ready to create our first project so to do that let’s go to our desktop here and let’s create a folder that is going to store our project I’m gonna call it my awesome program and right now this is of course completely empty let’s go ahead and fill this up with a project to do that we go inside of this code.
We hit open folder we navigate to the my awesome program folder and hit select and as we can see it’s now opened up in BS code but of course it’s still completely empty so let’s create a new project in here to do that we go to terminal at the top here and create a new terminal this is a command line interface that allows us to call certain commands and as you can see here we’re currently inside of the my awesome program folder on my desktop so we can go ahead and call a command in here called dotnet space new in order to create a new project here.
We’re then going to type console in order to use the simple console template that’s it enter and as you can see this creates some files in our project the most important one is the program dot CS file this is the meed of our program and it’s why we’re going to write our first lines of code now for some of you the font size might be very small by default so to change this we can go up to view and open up the command palette you can also press control shift P.
What this allows us to do is search through all kinds of commands in our case we want to change some user settings so let’s simply search for user settings and indeed here we can open the Preferences and go under user settings and right here we can change the font size now I’m just gonna set this to something like 24 and I’m also going to search at the top here for code lens and here where it says edit their code lens I’m going to disable that what this does is it overlays some extra information on top of your code and I find that’s a bit confusing for a beginner so I recommend just turning this off and that’s it for a setup now we’re not going to get into the code itself in this video instead.
I’ll just quickly show you how to run your program as you’re going to be doing that a lot now if we look at our code here we can see that by default that’s a bit in here and this might look really scary but for now we can ignore everything except this line right here this line writes out the words hello world in our console so if we run our program now it should simply display hello world to run our program we can go to our terminal and type dotnet space run and hit enter and indeed it says hello world but typing in this command every time we want to run our code is a bit annoying instead we can tell V s code how to run our program let’s again press ctrl shift P to open up the command palette let’s search for generate and select dotnet generate assets for build and debug and as you can see this creates two new files in our program folder launch and tasks these files tell V s code.
How to run our code while we’re working on the program by default these are set up correctly except that we want a program to open in a new window when we run it instead of just having it down here in the internal console so to change this we go into a launch dot JSON file and look for a property called console and we’re simply going to change this from internal console to external terminal with a non capital e and a capital T.
Now if we save this and go to our program we can actually run our code by simply going run start debugging and what you’ll see here is a bunch of things happening you will see some things flashing on your screen you will see things printed in the debug console and you might even see a window quickly open and then close immediately and the reason for this is not that our program didn’t run it did actually start but it also closed as soon as the program was finished and right now it’s finished as it said hello world.
So we didn’t even really get a chance to see it so to fix this let’s add a line underneath here so I’m gonna add a new line here and this line here is going to tell our program to wait for some input before closing for now we can just write after me I’m going to type console dot read key and remember your capitalization is important here open and close parenthesis and a semicolon so this line is simply going to say hey we’re going to wait for any kind of input from our keyboard and this way if we save this and go run our program so we’ll go to run start debugging or you can simply press f5.
We can indeed see that it opens up it displays hello world and when we then press a key I’m just going to press the spacebar here the program is finished and it closes automatically awesome so that’s our first program and that’s pretty much it for this video if you enjoyed it make sure to subscribe and ring that notification bell so dome is the next one in the next video we’re going to start writing some code also don’t forget.
Check out Jason’s course on game architecture learn how to write clean game code by simply clicking the link in the description and get the game dev mastery course included for free and that thanks for watching and I will see you in the next video thanks of the awesome patreon supporters who donated in April and a special thanks to – blank lost violin stuff forever free Samara Phi John replica studios SRT Mike Lewis set Jason you Tesco Navi ninja belivet Annan Daniel – Sonic donor team Gascoigne tantus Sam Jacob Sanford Noah Kiowa sake mark and 20-yard Gregory Pierce Michael cor above the mighty Zeus oven Cooper else in the Pierce Erasmus and serious you guys Rock