Read from location on console C#(从控制台 C# 上的位置读取)
问题描述
我需要从控制台中的特定位置读取文本,例如 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# 上的位置读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从控制台 C# 上的位置读取


基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01