Show / Hide Table of Contents

Property print.writer


Overload

Gets or sets object that actually writes text when is called print.it.

public static TextWriter writer { get; set; }
Property Value
TextWriter

Remarks

If you want to redirect or modify or just monitor output text, use code like in the example. It is known as "output redirection". Redirection is applied to whole process, not just this thread. Redirection affects print.it, print.redirectConsoleOutput and print.redirectDebugOutput. It does not affect print.directly and print.clear. Don't call print.it in method WriteLine of your writer class. It would call itself and create stack overflow. Call print.directly, like in the example.

Examples

print.writer = new OutputWriterWithTime();

print.it("test");

class OutputWriterWithTime :TextWriter {
	public override void WriteLine(string value) { print.directly(DateTime.Now.ToString("T") + ".  " + value); }
	public override Encoding Encoding => Encoding.Unicode;
}