Created
September 16, 2021 11:15
-
-
Save zetroot/72088c070bc127a5620d2219eb471d0c to your computer and use it in GitHub Desktop.
Capture stdout and redirect Console to null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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