The difference between ReadKey() and ReadKey(true) in C#

Console.ReadKey()

"Get a character or function key pressed by the user", ReadKey()the function has no parameters , and the pressed key is displayed in the console window.

Console.ReadKey(true)

ReadKey()functionaloverload, ReadKey(bool intercept)the function has a parameter , which determines whether to display the pressed key in the console windowtrue , means not to display the pressed key, and falsemeans to display the pressed key

Summarize:

Obviously, when the parameter falseis , the function is the same as without the parameter, so when we use ReadKey, there Console.ReadKey()are Console.ReadKey(true)two common situations, in which the former displays a character obtained, and the latter does not.

Guess you like

Origin blog.csdn.net/weixin_64072619/article/details/131317716