How to get actual integer input from Console?

Dec 7 2004 11:53 PM
How to get actual integer input from Console? There are 2 scenarios. 1. If we use Console.Readline(), it will return string. We can use Int32.parse(string) to convert the input to integer. Is Console.ReadLine() is good if input is only one character say 'Y' 2. If we use Console.Read(), it will accept character and return integer. It is good for those input where we are sure that input is like 'Y' or 'N'. Suppose input is 'A'. Then Console.Read() will return 65. Again we have to convert it to char to get 'A'.IS not this extra step? My question is which is better general/common appraoch for any type of input

Answers (1)