Bitcoin Forum
April 26, 2024, 06:56:24 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Beginners C# guide  (Read 52 times)
QuickAccount (OP)
Member
**
Offline Offline

Activity: 189
Merit: 52

In a world of coins, use them.


View Profile
September 03, 2021, 07:57:29 PM
Merited by OgNasty (1)
 #1

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:

Code:
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!


-

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 color
Before the first part of the code, type this to make your console text blue.

Code:
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!

Not your keys, not your coins.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!