Answers for "how to except a specific type of error with try catch c#"

0

how to except a specific type of error with try catch c#

using System;
					
public class Program
{
	public static void Main()
	{
		int x = 10 ;
		int i = 0 ;
		try{
			int result = x/i ;
			Console.WriteLine("the result is {0}",result) ;
			
		}
		catch(DivideByZeroException){
			Console.WriteLine("You are triying to divide by zero") ;
		}
	}
}
Posted by: Guest on October-31-2021

Code answers related to "how to except a specific type of error with try catch c#"

Browse Popular Code Answers by Language