I am going to implement a class which will catch error only once and process an error more than once which would depend on user, it means how many times user want to process that error. In this class 'n' represent how many times you want to process an error. If you want to process an error three times, you just need to change '3' at the place of 'n'.
using System;
class student
{
public static void Main(String[] args)
{
int a = 3;
int b = 0;
int result;
for (int i = 0; i < n; i++)
{
try
{
result = a / b;
Console.WriteLine(result);
}
catch (Exception ex)
{
Console.WriteLine("error is" + ex.Message);
}
}
}
}
That’s it!!…..Happy Programming...
No comments:
Post a Comment