i have following problem:
I am making a Windows Forms application and have to use other .cs Files which contain Console.Read() or Console.ReadLine(). The files should not be changed. I would like now to override the functions in order to use a button or a Textbox + Button instead of the Console.Read().
Since i should not change the .cs files, this seems not to be too trivial. Any ideas or leads?
You can access the Console
as a stream using:
var stdIn = Console.OpenStandardInput();
Then when you click the button, you can call
stdIn.Write(Encoding.ASCII.ToBytes(txtMyBuffer.Text), 0, txtMyBuffer.Text.Length);
From reference: https://msdn.microsoft.com/en-us/library/system.console.openstandardinput(v=vs.110).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.