Код: Выделить всё
var b1 = Console.IsOutputRedirected;
Console.SetOut(new StringWriter());
var b2 = Console.IsOutputRedirected;
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true });
var b3 = Console.IsOutputRedirected;
Console.WriteLine(b1);
Console.WriteLine(b2);
Console.WriteLine(b3);
Код: Выделить всё
False
True
False
Код: Выделить всё
False
False
False