From 4511f7ab84afeebeb6c720a0cd1a6c08e995de83 Mon Sep 17 00:00:00 2001 From: kirkorovka <147087189+kirkorovka@users.noreply.github.com> Date: Mon, 6 May 2024 18:25:36 +0400 Subject: [PATCH] LabWork5 --- .../MassiveGenericObjects.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Project_SelfPropelledArtilleryUnit/Project_SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs b/Project_SelfPropelledArtilleryUnit/Project_SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs index 9a9e03d..5c29324 100644 --- a/Project_SelfPropelledArtilleryUnit/Project_SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/Project_SelfPropelledArtilleryUnit/Project_SelfPropelledArtilleryUnit/CollectionGenericObjects/MassiveGenericObjects.cs @@ -12,9 +12,25 @@ public class MassiveGenericObjects : ICollectionGenericObjects { private T?[] _collection; public int Count => _collection.Length; - public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } } + public int SetMaxCount + { + set + { + if (value > 0) + { + if (_collection.Length > 0) + { + Array.Resize(ref _collection, value); + } + else + { + _collection = new T?[value]; + } + } + } + } + - public MassiveGenericObjects() { _collection = Array.Empty();