Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

6.Write a program to demonstrate System exception.

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication6

{

class Program

{

static void Main()

{

int a, b;

int[] arr = new int[5];

Console.WriteLine("Enter the value of A and B");

a = int.Parse(Console.ReadLine());

b = int.Parse(Console.ReadLine());

try

{

int x = a / b;

Console.WriteLine("The value of X after a/b is=" + x);

arr[10] = 25;

}

catch (Exception e)

{

Console.WriteLine(e);

Console.WriteLine("Message=" + e.Message);

}

Console.ReadLine();

}

}

}

Post a Comment

0 Comments