Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道如何设置控制台的光标位置,但是在创建新行时,光标会移回控制台的左侧。
如何在保留光标x坐标的同时设置光标位置并写入多行?
x
注意:请注意,我可以选择为每一行设置光标位置,因为我的文本块经常改变大小。
void WriteLineKeepingIndent(string format, params object[] args) { int x = Console.CursorLeft; Console.WriteLine(format, args); Console.CursorLeft = x; }
您应该使用其中一种