Suppress 3rd party library console output?

前端 未结 2 1160
余生分开走
余生分开走 2021-02-04 05:06

I need to call a 3rd party library that happens to spew a bunch of stuff to the console. The code simply like this...

int MyMethod(int a)
{
   int b = ThirdPart         


        
2条回答
  •  不思量自难忘°
    2021-02-04 05:50

    Well you can use Console.SetOut to an implementation of TextWriter which doesn't write anywhere:

    Console.SetOut(TextWriter.Null);
    

    That will suppress all console output though. You could always maintain a reference to the original Console.Out writer and use that for your own output.

提交回复
热议问题