Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #reflection #resize #array
ADD COMMENT
Topic
Name
5+6 =