Hey guys! Im bored at school so im gonna share some of my knowledge that I used when I learned my first programming language, C#!
Prerequisites:
1. A windows machine - Any windows computer with an OK CPU, for compiling your programs.
2. Visual Studio Community Edition (Not Visual Studio Code) - Just download it from Microsoft's website, I recommend VS 2019
3. Some free time - to follow this guide start to finish it will take a bit, so clear your schedule!
4. A learning mindset - Remember, learning programming isnt easy, so take breaks if needed.
Starting:
Fire up your favorite installation of Visual Studio and you should be presented with this screen:
Once your on this screen, click the button highlighted in red. Once you do that you should see this screen:Call the project what ever you want.
Click next until you get to this screen:
Great! This is your first hello world application, it simply outputs "Hello World!" then closes.We are gonna spice this up a little bit and make it personal with inputs! The first project you will learn is how to make a simple application that outputs whatever you type.
Delete the "Console.WriteLine("Hello world!")" and type this out, Remember, Dont copy and paste the code from this post, type it manually. It will help you learn:
String text = Console.ReadLine(); Console.WriteLine(text); Console.ReadKey();
Im gonna explain this code real quick: "
String text = Console.ReadLine(); is declaring a string, also called a plain text variable, named text, and sets the value of it to "
Console.ReadLine();" which initiates the console to take input when type in and enter is pressed, ";" ends the line. "
Console.WriteLine(text);" writes a line to the console with the value of our text variable we declared. It then ends the line with ";". Lastly,
Console.ReadKey(); this was put in so that the project doesnt close as soon as it runs, it closes without this because we dont pause it from running the whole script and then exiting.
Now lets take it for a test drive! Click ctrl + f5 or click this button at the top of the screen to run your program! ![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fvisualstudio%2Fget-started%2Fcsharp%2Fmedia%2Fvs-start-button.png%3Fview%3Dvs-2019&t=665&c=m_dy7o2oYk-Stw)
-
Now when the console appears, type what ever you want and it will output it! This simple input code can be used for an infinite amount of things!Lets style your console a little bit, lets change the text colorBefore the first part of the code, type this to make your console text blue.
Console.ForegroundColor = ConsoleColor.Blue
Run your program and type, your text will be blue!Im about to get out of school for the day, I will add much more to this guide on monday, cheers!