An exercise to handle the DivideByZeroException
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// {
using System;
namespace ExceptionHandling
{
public class CalculationHelper
{
// }
public static int Calculate10DividedBy(int value)
{
return 10 / value; //if the value is 0, this will throw a DivideByZeroException, so to fix it, handle the exception and return a int.MaxValue when exception is caught
}
// {
}
}
// }
Press desired key combination and then press ENTER.
1
using Microsoft.VisualStudio.TestTools.UnitTesting;
Press desired key combination and then press ENTER.