Writing Console Output C# with Example



Writing Console Output C# with Example

 using System.IO;
using System;

namespace CSharpFilesAndStreams
{
	class ErrOut 
	{
		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);
			}
		}
	}
}	 

0 Comment's

Comment Form

Submit Comment