Answers for "c# how to resize an array"

C#
1

c# reflection resize array

static void Resize(ref Array array, int newSize) {        
    Type elementType = array.GetType().GetElementType();
    Array newArray = Array.CreateInstance(elementType, newSize);
    Array.Copy(array, newArray, Math.Min(array.Length, newArray.Length));
    array = newArray;
}
Posted by: Guest on April-14-2021

Code answers related to "c# how to resize an array"

C# Answers by Framework

Browse Popular Code Answers by Language