From: SnapDive on

I have a C# 3.5 console app with many WriteLine calls. I want to add a
startup argument to make all WriteLines write to "nul" so the app can
run silently at my option. I don't want to clutter the code with a lot
of if statements around the WriteLines or etc. There should be some
way to just declare what the "console" is, right?

Thanks.


From: Bert Hyman on
In news:4km3t5137j7sld9tvoetdkf2r2aif24iu0(a)4ax.com SnapDive
<SnapDive(a)community.nospam> wrote:

> There should be some way to just declare what the "console" is, right?
>

Console.SetOut can change the TextWriter stream.

--
Bert Hyman St. Paul, MN bert(a)iphouse.com
From: Michael Wojcik on
SnapDive wrote:
> I have a C# 3.5 console app with many WriteLine calls. I want to add a
> startup argument to make all WriteLines write to "nul" so the app can
> run silently at my option. I don't want to clutter the code with a lot
> of if statements around the WriteLines or etc.

Just spell your argument ">nul".

Yes, you could use System.Console.SetOut(System.IO.TextWriter.Null),
but why reinvent this wheel?

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
 | 
Pages: 1
Prev: Upload/Update files on a server
Next: email