довлена необязательная проверка при удалении

This commit is contained in:
tyxz0 2024-04-28 23:27:04 +04:00
parent 5aa1c71b4c
commit a323b124aa
2 changed files with 5 additions and 2 deletions

View File

@ -42,7 +42,7 @@ public class ListGenericObjects<T> : ICollectionGenericObjects<T>
public int Insert(T obj, int position) public int Insert(T obj, int position)
{ {
if (Count >= _maxCount || position < 0 || position > _maxCount) if (Count >= _maxCount || position < 0 || position >= _maxCount)
{ {
return -1; return -1;
} }

View File

@ -52,7 +52,10 @@ public class StorageCollection<T>
public void DelCollection(string name) public void DelCollection(string name)
{ {
_storages.Remove(name); if (_storages.ContainsKey(name))
{
_storages.Remove(name);
}
} }
public ICollectionGenericObjects<T>? this[string name] public ICollectionGenericObjects<T>? this[string name]