-3

Sorry, I've just started programming in C#. I would like to know what's the easiest way to read a character or characters from the console and store the value into a variable to be written to the console at a later point.

Thank you!

csiu
  • 3,159
  • 2
  • 24
  • 26
AVrolet
  • 43
  • 4
  • 2
    Are you familiar with any of the `Console` class API? Like, `Console.Read` ? – Mark C. Oct 08 '16 at 22:49
  • 4
    Possible duplicate of [How to read char from the console](http://stackoverflow.com/questions/19860677/how-to-read-char-from-the-console) – Dan Mindru Oct 08 '16 at 22:59
  • @MarkC. Not really, I'm really at the beginning of learn the programming. Thank you for quick answer! – AVrolet Oct 08 '16 at 23:08

1 Answers1

2

That would be:

string input = Console.ReadLine();
haindl
  • 3,111
  • 2
  • 25
  • 31
  • 3
    There's much more of a learning opportunity here for the OP than just answering the question, in my opinion. – Mark C. Oct 08 '16 at 22:49
  • 1
    @MarkC. You are absolutely correct! I just wanted to do him a favor and give him a quick starting point. – haindl Oct 08 '16 at 22:51
  • 1
    Sure, and I agree with you, but teaching OP that they could go to the `Console` class and look at the API with notes could lead to some valuable learning (I am assuming that they didn't know that they could do that). +1 anyway. Cheers! – Mark C. Oct 08 '16 at 22:52