Given some array:
int[] array = new int[8000];
Is it possible to refer to a new array such that:
int[] array2 = Array.SameReferenceDifferentLength(array, 4000);
home / developersection / forums / create new reference to array with different length
Given some array:
int[] array = new int[8000];
Is it possible to refer to a new array such that:
int[] array2 = Array.SameReferenceDifferentLength(array, 4000);
Anonymous User
05-Oct-2013var a = new string[] { "a", "b", "c", "d", "e" };var b = new ArraySegment<string>(a, 1, 3);
foreach (var s in b)
{
Console.WriteLine(s);
}
This makes a shallow reference to the specified range of the array. That is, it doesn't copy the array data.
If you want to index an ArraySegment<T>, you can cast it to a IList<T> then use the indexer provided by that interface.