41
1
using static System.Console;
2
using System;
3
public class Program
4
{
5
public static void Main()
6
{
7
8
WriteLine("\nException catched");
9
try
10
{
11
Callthis("1");
12
}
13
catch(Exception ex)
14
{
15
if(ex.Message.Equals("1"))
16
WriteLine("Error occurred -> 1");
17
else
18
throw ;
19
}
20
21
WriteLine("\nException not catched");
22
try
23
{
24
Callthis("2");
25
}
26
catch(Exception ex)
27
{
28
if(ex.Message.Equals("1"))
29
WriteLine("Error occurred -> 1");
30
else
31
throw ;
32
}
33
}
34
35
public static void Callthis(string i)
36
{
37
38
throw new Exception(i);
39
40
}
41
}
Cached Result