-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (36 loc) · 993 Bytes
/
Program.cs
File metadata and controls
41 lines (36 loc) · 993 Bytes
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
Process1();
Console.WriteLine("Exit program");
static void Process1()
{
try
{
WriteMessage();
}
catch (DivideByZeroException ex)
{
// This block will catch the DivideByZeroException thrown in WriteMessage
Console.WriteLine("Exception caught in Process1");
Console.WriteLine(ex.Message);
}
catch (Exception ex)
{
// This block will catch any other exceptions
Console.WriteLine("General exception caught in Process1");
Console.WriteLine(ex.Message);
}
finally
{
Console.WriteLine("Exception caught in Process1");
}
}
static void WriteMessage()
{
double float1 = 3000.0;
double float2 = 0.0;
int number1 = 3000;
int number2 = 0;
// This line will print "Infinity" (or similar, as double division by zero doesn't throw)
Console.WriteLine(float1 / float2);
// This line will throw the DivideByZeroException
Console.WriteLine(number1 / number2);
}