从控制台 C# 上的位置读取

Read from location on console C#(从控制台 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# 上的位置读取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Custom Error Queue Name when using EasyNetQ for RabbitMQ?(使用 EasyNetQ for RabbitMQ 时自定义错误队列名称?)
How to generate password_hash for RabbitMQ Management HTTP API(如何为 RabbitMQ 管理 HTTP API 生成密码哈希)
Rabbitmq Ack or Nack, leaving messages on the queue(Rabbitmq Ack 或 Nack,将消息留在队列中)
Setup RabbitMQ consumer in ASP.NET Core application(在 ASP.NET Core 应用程序中设置 RabbitMQ 消费者)
Specify Publish timeouts in mass transit(指定公共交通中的发布超时)
RabbitMQ asynchronous support(RabbitMQ 异步支持)