views:

64

answers:

3

Basically I'm still in the starting phase, and I know how to use console.writeline, but I have no idea on how to have it read input from the user.

For example, I'd want a user to be able to type in a pair of numbers, then return the result.

My goal is a program that receives input , then combines them and returns the average.

This is all in Visual C# Express 2008

A: 

This is a very general topic with a lot of answers, but Console.ReadLine is one counterpart of Console.WriteLine. It reads a line of text from standard in.

Matthew Flaschen
+3  A: 
string input = Console.ReadLine();

that will return you a string of the user's input. Check out MSDN for documentation on the Console class. Also look at the Convert class.

int num = Convert.ToInt32(input);

Good luck new coder.

Khalid Abuhakmeh
A: 

Have a look at Console.ReadLine() or Console.Read() in the MSDN Documentation

Matt Bridges
Ok, I see how to obtain data. How do I actually store it? Like, if I want to return a solution that's based on several pieces of data that have been input?
Slateboard
@Slateboard - for temporary storage, in variables or properties. You might want to go through a few tutorials or pick up an introductory C# book.
TrueWill