From 443199e870fae9e24b5feca42e04358878cb4ea6 Mon Sep 17 00:00:00 2001 From: mar-va Date: Wed, 3 Apr 2024 17:32:55 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=964?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ListGenericObjects.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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; } + + }