Publishing System Settings Logout Login Register
C# - A Basic Understanding
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on March 16th, 2010
3470 views
C#

Accepting User Input

The most important part of programming is accepting user input and manipulating the data that they provide. To demonstrate I will show you how to create a simple program which asks the user for there name and then will output "Hello, [name]."

Here is the code to do this:

string name = "";
Console.WriteLine("What is your name?");
name = Console.ReadLine();
Console.WriteLine("Hello, " + name);
Console.ReadLine();

This incorporates everything we've learned so far with one new addition.

name = Console.ReadLine();

This is quite self explanatory all it does is take whatever the user types and places it in the variable name. Then all we do is output it with the normal Console.WriteLine.

So now you have all you need to start making some basic programs involving variables. user input, basic calculations and outputing data. Look out for further tutorials that will continue into if statements, loops and arrays.

Pages: 1 2 3 4 5
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
chironic

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top