C# Console SetError
Description
Console SetError
sets the Error property to the specified
TextWriter object.
Syntax
Console.SetError
has the following syntax.
[HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)]
public static void SetError(
TextWriter newError
)
Parameters
Console.SetError
has the following parameters.
newError
- A stream that is the new standard error output.
Returns
Console.SetError
method returns
Example
using System;/*from w w w. j a v a 2 s .c o m*/
using System.IO;
public class InsertTabs {
public static void Main(){
try {
StreamWriter writer = new StreamWriter("data");
Console.SetError(writer);
}
catch(IOException e) {
TextWriter errorWriter = Console.Error;
errorWriter.WriteLine(e.Message);
}
}
}