C# 如何在控制台应用程序中获取光标的位置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10483459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get the position of the cursor in a console app?
提问by scott
I would like to be able to check that the position of the cursor hasn't moved past a certain point. I haven't been able to find anything that gives the position of the text cursor via google. I'm not really sure where else to look.
我希望能够检查光标的位置是否没有移动超过某个点。我一直无法通过谷歌找到任何给出文本光标位置的东西。我不太确定还能在哪里看。
采纳答案by Chris Dunaway
Look at the various methods and properties of the Console class. Specifically, using Console.CursorLeft and Console.CursorTop, you can get and set the position of the cursor.
查看 Console 类的各种方法和属性。具体来说,使用 Console.CursorLeft 和 Console.CursorTop 可以获取和设置光标的位置。
回答by RajN
Use Console.CursorLeft and Console.CursorTop
使用 Console.CursorLeft 和 Console.CursorTop
Please look at this MSDN link for more information
请查看此 MSDN 链接以获取更多信息

