I am new to C#, and am wondering how to do the following:
I create an array whose size of the maximum number of elements I will need to store:
int[] myArray = new int[64000];
I am passing this array to a 3rd party API. In this API, they use the .Length property to determine the number of elements. I don't want this to happen because the array length is the maximum count, not the "active count" (i.e. the number of elements in use).
With this in mind, is there a way to create another array, whose size equals the active count? And, can this be done without a copy and/or allocation? I already have the allocated memory -- all I want to do is indicate the subregion of interest while playing nicely with the 3rd party API.
Listrather than an array, if you do not know exactly how many items will be in the collection.