I tried to write a function that remove special character from console..
Example, if I write:
Console.WriteLine("Hello World");
After I call the function with character ‘o’ , the console will be like:
"Hell Wrld"
I thought about running all over the console with
Console.SetCursorPosition(i,j);
but I can not get the value of “CursorPosition”..
Any idea?
There is no way for you to read what has already been written to the console. One thing that you can do however is to provide your own output stream. You could make your own
TextWriterimplementation that is given the original output stream along with the filter characters. Then you can set the console’s output stream to your new one, and after that anytime anyone writes to your programs output stream it will filter the character you choose.I’ve run a few simple tests with the following lines of code, and it seems to be working just fine. Let me know if it doesn’t cover any more complex cases.
Elsewhere in Main or somewhere: