From bd5c546794354de5cd6ba19dd30b70a2f5fcca54 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Thu, 10 Mar 2022 21:24:50 +0000 Subject: [PATCH] Added bounds search on Linked List --- C#/Datastructures/LinkedList.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C#/Datastructures/LinkedList.cs b/C#/Datastructures/LinkedList.cs index f553ab8..8053a94 100644 --- a/C#/Datastructures/LinkedList.cs +++ b/C#/Datastructures/LinkedList.cs @@ -46,7 +46,7 @@ namespace C_.Datastructures get { //Check Range - if (i >= Count) throw new System.Exception("Error! Index out of Bounds"); + if (i >= Count || i < 0) throw new System.Exception("Error! Index out of Bounds"); //Return Value LinkedListNode? node = Traverse(i); @@ -56,7 +56,7 @@ namespace C_.Datastructures set { //Check Range - if (i >= Count) throw new System.Exception("Error! Index out of Bounds"); + if (i >= Count || i < 0 ) throw new System.Exception("Error! Index out of Bounds"); //Change Value LinkedListNode? node = Traverse(i);