Skip to content

Instantly share code, notes, and snippets.

@zetroot
Created September 16, 2021 11:15
Show Gist options
  • Save zetroot/72088c070bc127a5620d2219eb471d0c to your computer and use it in GitHub Desktop.
Save zetroot/72088c070bc127a5620d2219eb471d0c to your computer and use it in GitHub Desktop.
Capture stdout and redirect Console to null
using System;
using System.IO;
var stdout = Console.Out;
Console.SetOut(StreamWriter.Null);
Console.WriteLine("this goes to null");
stdout.WriteLine("this goes to standart output");
Console.Out.WriteLine("and this goes to null again");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment