From 052b9929c1bb5d3c4817bec6d2047e30928bd35c Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Sun, 28 Apr 2024 00:20:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=204?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MassivGenericObjects.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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)