Write to Console.Out and Console.Error : Console Input Output : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Console Input Output »

 

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


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Console Input Output