Say I have an array
array<double>^ buffer = gcnew array<double>(100);
And I want a function that does something like:
void foo(array<double>^% buffer)
{
Array::Resize(buffer, 10);
}
but that don’t allocate and/or move &buffer[0] when you want to trim the array.
.NET arrays are immutable in size once created. You can’t trim it; you must reallocate and copy. So
Array.Resizealready does everything you need. Perhaps just ignore the elements at the end if you really don’t want to do this.Or; use a
List<T>, which encapsulates an array, and does haveTrimExcess(). In C# terms: