From f9ab601a451849b8b616741514f8f5c02ad3f8e5 Mon Sep 17 00:00:00 2001 From: Ahmed Deghady <52136140+ahmed-fawzy99@users.noreply.github.com> Date: Wed, 7 Sep 2022 13:32:17 +0200 Subject: [PATCH] Update replace-exception-with-test_after.cs The previous code did not check for negative index values --- simple/csharp/replace-exception-with-test_after.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simple/csharp/replace-exception-with-test_after.cs b/simple/csharp/replace-exception-with-test_after.cs index 5ec5f68..8ea0acc 100755 --- a/simple/csharp/replace-exception-with-test_after.cs +++ b/simple/csharp/replace-exception-with-test_after.cs @@ -1,8 +1,8 @@ double GetValueForPeriod(int periodNumber) { - if (periodNumber >= values.Length) + if (periodNumber >= values.Length || periodNumber < 0) { return 0; } return values[periodNumber]; -} \ No newline at end of file +}