diff --git a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs index 1eb13ec..b16bb18 100644 --- a/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectAccordionBus/ProjectAccordionBus/CollectionGenericObjects/ListGenericObjects.cs @@ -9,7 +9,7 @@ namespace ProjectAccordionBus.CollectionGenericObjects; public class ListGenericObjects : ICollectionGenericObjects where T : class { - private readonly List _collection; + private readonly List _collection; private int _maxCount; public int MaxCount => _maxCount; @@ -32,15 +32,21 @@ public class ListGenericObjects : ICollectionGenericObjects public int Insert(T obj) { - if (_collection == null || _collection.Count == _maxCount) return -1; + if (Count == _maxCount) + { + return -1; + } _collection.Add(obj); - return _collection.Count - 1; + return _collection.Count; } public int Insert(T obj, int position) { - if (_collection == null || position < 0 || position > _maxCount) return -1; + if (Count == _maxCount || position < 0 || position > Count) + { + return -1; + } _collection.Insert(position, obj); return position; @@ -54,4 +60,6 @@ public class ListGenericObjects : ICollectionGenericObjects _collection[position] = null; return obj; } + + }