从位置阅读控制台C# [英] Read from location on console C#

查看:104
本文介绍了从位置阅读控制台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?

只是为了澄清:
我并不想停止接受来自用户的输入,甚至还有输入将无法从用户的事,但previously打印出来的机会。我简直要某种:
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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆