diff --git a/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs b/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs index f2c2d7f..6245de1 100644 --- a/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs +++ b/ProjectStormtrooper/ProjectStormtrooper/SetGeneric.cs @@ -71,17 +71,17 @@ namespace ProjectStormtrooper public T? Remove(int position) { // Проверка позиции - if (position < 0 || position >= Count) + if (position < 0 || position >= _maxCount) { return null; } - // Удаление объекта из массива, присвоив элементу массива значение null - T? plane = _places[position]; - if (plane == null) + if (position >= Count && position < _maxCount) { throw new PlaneNotFoundException(position); } - _places[position] = null; + // Удаление объекта из массива, присвоив элементу массива значение null + T? plane = _places[position]; + _places.RemoveAt(position); return plane; } ///