diff --git a/ProjectStormTrooper/ProjectStormTrooper/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectStormTrooper/ProjectStormTrooper/CollectionGenericObjects/MassiveGenericObjects.cs index e533580..e957d1b 100644 --- a/ProjectStormTrooper/ProjectStormTrooper/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectStormTrooper/ProjectStormTrooper/CollectionGenericObjects/MassiveGenericObjects.cs @@ -54,12 +54,11 @@ public class MassiveGenericObjects : ICollectionGenericObjects public bool Insert(T obj) { - for (int i = 0; i < _collection.Length; i++) + int index = Array.IndexOf(_collection, null); + if(index >= 0) { - if (_collection[i] == null) { - _collection[i] = obj; - return true; - } + _collection[index] = obj; + return true; } return false; }