Write to Console.Out and Console.Error
/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Write to Console.Out and Console.Error.
using System;
public class ErrOut {
public static void Main() {
int a=10, b=0;
int result;
Console.Out.WriteLine("This will generate an exception.");
try {
result = a / b; // generate an exception
} catch(DivideByZeroException exc) {
Console.Error.WriteLine(exc.Message);
}
}
}
Related examples in the same category