Introduction: Write Your First C# Code (For Windows)!
In this instructable, I am going to graciously teach you all how to create your very own code in the C# language! All you're going to need is a computer/laptop and a little bit of patience. Apart from the download time, this will take you only about 10 minutes to complete! Ready? Simply follow these 7 easy steps.
Step 1: Download the Visual Studio IDE
The first step you want to do is download the software that you'll be coding on! The software that we are going to use in this instructable is Visual Studio. Make sure that you download the Community 2017 edition so that you are not charged any money. I'll place a link to the website just to make things a little easier. https://visualstudio.microsoft.com/
Step 2: Installation
Now the Visual Studio IDE is already a MASSIVE file and it takes up a lot of memory on it's own. If you choose to install all of the features it offers, this amount multiplies intensely. DO NOT INSTALL EVERYTHING. Since we will be programming a simple code in C#, ONLY install the 3 features that are listed under the "Windows" panel. This process will take quite a long time so, find something to occupy yourself with for a while.
Step 3: Creating Your First Project
Now the first thing you want to do when you first open the Visual Studio IDE is sign in with your Microsoft Account but that takes 2 seconds and I don't think I have to teach you how to do that. What I will teach you, is how to navigate to where you'll be creating your first program. Under "New Project" click on "Create new project...". You will then need to click "Visual C#" from the panel on the left and choose the "Console App (.NET Framework)" option and select "Ok". Be sure to use the images posted for visual representation.
Step 4: Creating the WriteLine
Now what you see in front of you may seem very intimidating at first glance but I assure you it is not. For now, we are only going to worry about one section of this code. Locate the line with the method "static void Main(string args)". We will be working within the curly brackets that follow this line. Within those curly brackets type, " Console.WriteLine(""); ". Be sure to write this exactly how I have written it since C# is a case-sensitive language.
Step 5: Now You Be Creative!
Now that we have the command written out, it's your turn to be a programmer! Within the parenthesis of the Console.WriteLine("") command, put anything that you want the Console to output. This can be your name, a set of numbers, an essay, you decide. Just make sure that you STAY WITHIN THE PARENTHESIS.
Step 6: Allowing the Console to Output
Now if we were to run this program on Windows, the program would run, output whatever you wrote, and immediately close before you could see anything. On Mac you will not encounter this problem but then again, this tutorial isn't for Mac users. To prevent the console from immediately closing, we will use a command called "Console.ReadKey();". You could also use a command called "Console.ReadLine();" but this is bad practice so stick to the first command I gave you.
Step 7: Run Your Program Programmer!
That's it! You're now a programmer, congrats! Now that you're a programmer, make sure you always save your work to assure that there is no loss of your work. To save your program simply press "CTRL + S" on your keyboard. Now to output your code. There is the "START" button at the top of the page. Press that, and voila! Whatever you wrote inside of those parenthesis should be on your screen. If not, make sure you end every line with a semi-colon and check for grammatical errors.