diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs index ef399d3..6538e5b 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs @@ -11,14 +11,21 @@ namespace HoistingCrane.CollectionGenericObjects public int Count { get { return arr.Length; } - } + } public int SetMaxCount { set { if (value > 0) { - arr = new T?[value]; + if (arr.Length > 0) + { + Array.Resize(ref arr, value); + } + else + { + arr = new T?[value]; + } } } } @@ -33,14 +40,7 @@ namespace HoistingCrane.CollectionGenericObjects public int Insert(T obj) { - for (int i = 0; i < Count; i++) - { - if (arr[i] == null) - { - return Insert(obj, 0); - } - } - return -1; + return Insert(obj, 0); } public int Insert(T obj, int position)