-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserDefinedException.cs
84 lines (75 loc) · 1.54 KB
/
UserDefinedException.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Runtime.Serialization;
namespace ConsoleApp51
{
public class Test
{
public static void Main()
{
try
{
int a = 1;
int b = 1;
var result = Division(a, b);
Console.WriteLine(result);
Temprature temp = new Temprature();
temp.showTemp();
}
catch (DivideByZeroException e)
{
Console.WriteLine(e);
}
catch (Exception e)
{
Console.WriteLine(e);
}
finally
{
Console.WriteLine("Hello Mr. Raverkar");
}
}
private static int Division(int a, int b)
{
return a / b;
}
class Temprature
{
int temprature = 0;
internal void showTemp()
{
try
{
if(temprature == 0)
{
throw (new TempZeroException ("Zero Temprature"));
}
else
{
Console.WriteLine("Temprature is non zero");
}
}
catch(TempZeroException temp)
{
Console.WriteLine(temp);
}
}
}
}
[Serializable]
internal class TempZeroException : Exception
{
public TempZeroException()
{
}
public TempZeroException(string message) : base(message)
{
message = "The tempratuer is zero";
}
public TempZeroException(string message, Exception innerException) : base(message, innerException)
{
}
protected TempZeroException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}