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);
          
        }
    }
}




















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version