-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntroducing an Error.cs
39 lines (38 loc) · 980 Bytes
/
Introducing an Error.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Try_Catch_Finally_Deep_Dive
{
internal class Introducing_an_Error
{
public static void Example1()
{
string returnValue = GetValueFromMethod();
Console.WriteLine(returnValue.ToString());
}
private static string GetValueFromMethod()
{
string returnValue = "Initial Value";
try
{
int dividedByValue = 0;
if (100 / dividedByValue == 0)
{
}
return returnValue;
}
catch (Exception ex)
{
// throw ex;
return "Catch Value";
}
finally
{
// The memory will be cleared here
returnValue = "Finally Value";
}
}
}
}