我需要从控制台中的特定位置读取文本,例如 5,5.
I need to read text from a particular location in the console, say 5,5.
如果我需要写信到这个位置,那就是:
If I were to need to write to this location, it would simply be:
Console.SetCursorPosition(5, 5);
Console.Write("My text");
有什么方法可以用类似的方式阅读吗?
Is there any way i can read in a similar way?
只是为了澄清:我不想停下来接受用户的输入,甚至有可能输入不是来自用户,而是以前打印出来的.我真的想要某种:Console.GetCharAtLocation(5,5) 或类似的东西.
Just to clarify: I don't want to stop to take an input from the user, there's a chance even that the input won't be from the user, but something previously printed out. I literally want some sort of: Console.GetCharAtLocation(5,5) or something similar.
此功能不存在.从理论上讲,您可以覆盖控制台上的输入和输出流,以保留您自己可以读取的控制台缓冲区副本,但这并不重要(并且可能无法支持所有边缘情况,例如作为连接到您的控制台并对其进行读/写的外部程序).
This functionality doesn't exist. It's theoretically possible for you to override the input and output streams on the console to keep your own copy of the console buffer that you could read from, but it would be non-trivial (and probably couldn't support all of the edge cases such as an external program hooking into your console and reading/writing to it).
这篇关于从控制台 C# 上的位置读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!