Exportar (0) Imprimir
Expandir todo

Console.Error (Propiedad)

Obtiene la secuencia de salida de error estándar.

Espacio de nombres: System
Ensamblado: mscorlib (en mscorlib.dll)

public static TextWriter Error { get; }
/** @property */
public static TextWriter get_Error ()

public static function get Error () : TextWriter

Valor de propiedad

Un objeto TextWriter que representa la secuencia de salida de error estándar.

Esta propiedad se establece en la secuencia de error estándar de forma predeterminada. Esta propiedad puede establecerse en otra secuencia con el método SetError.

En el ejemplo de código siguiente se ilustra el uso de la propiedad Error.

public class ExpandTabs {
    private const int tabSize = 4;
    private const string usageText = "Usage: EXPANDTABSEX inputfile.txt outputfile.txt";
    public static int Main(string[] args) {
        StreamWriter writer = null;
        TextWriter standardOutput = Console.Out;

        if (args.Length < 2) {
            Console.WriteLine(usageText);
            return 1;
        }

        try {
            writer = new StreamWriter(args[1]);
            Console.SetOut(writer);
            Console.SetIn(new StreamReader(args[0]));
        }
        catch(IOException e) {
            TextWriter errorWriter = Console.Error;
            errorWriter.WriteLine(e.Message);
            errorWriter.WriteLine(usageText);
            return 1;            
        }
        int i;
        while ((i = Console.Read()) != -1) {
            char c = (char)i;
            if (c == '\t')
                Console.Write(("").PadRight(tabSize, ' '));
            else
                Console.Write(c);
        }
        writer.Close();
        // Recover the standard output stream so that a 
        // completion message can be displayed.
        Console.SetOut(standardOutput);
        Console.WriteLine("EXPANDTABSEX has completed the processing of {0}.", args[0]);
        return 0;
    }
}

public class ExpandTabs
{
    private static int tabSize = 4;
    private static String usageText =
        "Usage: EXPANDTABSEX inputfile.txt outputfile.txt";
    public static void main(String[] args)
    {
        StreamWriter writer = null;
        TextWriter standardOutput = Console.get_Out();
        if (args.length < 2) {
            Console.WriteLine(usageText);
            return;
        }
        try {
            writer = new StreamWriter(args[1]);
            Console.SetOut(writer);
            Console.SetIn(new StreamReader(args[0]));
        }
        catch (IOException e) {
            TextWriter errorWriter = Console.get_Error();
            errorWriter.WriteLine(e.get_Message());
            errorWriter.WriteLine(usageText);
            return;
        }
        int i;
        while (((i = Console.Read()) != -1)) {
            char c = (char)(i);
            if (c == '\t') {
                Console.Write("".PadRight(tabSize, ' '));
            }
            else {
                Console.Write(c);
            }
        }
        writer.Close();
        // Recover the standard output stream so that a 
        // completion message can be displayed.
        Console.SetOut(standardOutput);
        Console.WriteLine("EXPANDTABSEX has completed the processing of {0}.",
            args[0]);
        return;
    } //main
} //ExpandTabs

public class ExpandTabs {
    private static var tabSize : int = 4;
    private static var usageText : String  = "Usage: EXPANDTABSEX inputfile.txt outputfile.txt";
    public static function Main(args : String[]) : int {
        var writer : StreamWriter = null;
        var standardOutput : TextWriter = Console.Out;

        if (args.Length < 2) {
            Console.WriteLine(usageText);
            return 1;
        }

        try {
            writer = new StreamWriter(args[1]);
            Console.SetOut(writer);
            Console.SetIn(new StreamReader(args[0]));
        }
        catch(e : IOException) {
            var errorWriter : TextWriter = Console.Error;
            errorWriter.WriteLine(e.Message);
            errorWriter.WriteLine(usageText);
            return 1;            
        }
        var i : int;
        while ((i = Console.Read()) != -1) {
            var c : char = char(i);
            if (c == '\t')
                Console.Write(("").PadRight(tabSize, ' '));
            else
                Console.Write(c);
        }
        writer.Close();
        // Recover the standard output stream so that a 
        // completion message can be displayed.
        Console.SetOut(standardOutput);
        Console.WriteLine("EXPANDTABSEX has completed the processing of {0}.", args[0]);
        return 0;
    }
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition

.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.

.NET Framework

Compatible con: 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft