Search code examples
c#inputvisual-studio-express

How do I receive and store data input in C#?


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


Solution

  • 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.