C# - 没有新行的字符串 ReadLine
C# - string ReadLine without new line
我可以在 C# 中执行 ReadLine(我想读取字符串)而没有 ReadLine 之前的那个不可见的“\n”吗?
我想让它看起来像这样:
Type name:
$> (user types here)
但是在使用 ReadLine 时,我得到了这个:
Type name:
$>
(user types here).
如何更改光标位置以返回行?
也许你应该考虑Console.SetCursorPosition
您如何编写提示用户的文本?对于此行为,您应该使用 Console.Write(),而不是 .WriteLine() 将光标留在写入控制台的字符串的末尾。
另见this article进一步解释
我可以在 C# 中执行 ReadLine(我想读取字符串)而没有 ReadLine 之前的那个不可见的“\n”吗?
我想让它看起来像这样:
Type name:
$> (user types here)
但是在使用 ReadLine 时,我得到了这个:
Type name:
$>
(user types here).
如何更改光标位置以返回行?
也许你应该考虑Console.SetCursorPosition
您如何编写提示用户的文本?对于此行为,您应该使用 Console.Write(),而不是 .WriteLine() 将光标留在写入控制台的字符串的末尾。
另见this article进一步解释