0

Console.ReadKey

On C# What's the difference between: Console.Read(); Console.ReadLine(); Console.ReadKey(); ?? I know I need it to keep the terminal open when I code on VS on PC, and i know they all work, but what's the difference and which is the best to use?

16th Jan 2019, 2:52 PM
Lily Hua
2 Antworten
+ 4
Hi! Above snippets can be used to hold the program without exiting. But don't think that methods exist for that purpose - so there is nothing called best method to hold the console. And the real usage of them is to get user input. Not sure about the methods in c#, but as names suggests. Read will get a word , ReadKey will get a char, and ReadLine will get the string in the next line of the console as the user input Hope you got the answer
16th Jan 2019, 3:57 PM
Seniru
Seniru - avatar
+ 1
Thanks!! I didn't know about the lengths! Makes sense now.
17th Jan 2019, 9:41 PM
Lily Hua