Resize Array By Last and not by First in C#
Posted
by
Leen15
on Stack Overflow
See other posts from Stack Overflow
or by Leen15
Published on 2010-12-29T21:46:15Z
Indexed on
2010/12/29
21:53 UTC
Read the original article
Hit count: 159
Hi all!
I have an Array of Class elements, and by an int variable i need to resize this array to the last X elements.
So for example i have an array with:
Array[0] = Msg1
Array[1] = Msg2
Array[2] = Msg3
Array[3] = Msg4
Array[4] = Msg5
Array[5] = Msg6
Array[6] = Msg7
Array[7] = Msg8
Array[8] = Msg9
Array[9] = Msg10
and i need to have only the last 8 elements in the array.
i cannot use the Array.Resize function because the result would be:
Array[0] = Msg1
Array[1] = Msg2
Array[2] = Msg3
Array[3] = Msg4
Array[4] = Msg5
Array[5] = Msg6
Array[6] = Msg7
Array[7] = Msg8
and i need something like this:
Array[0] = Msg3
Array[1] = Msg4
Array[2] = Msg5
Array[3] = Msg6
Array[4] = Msg7
Array[5] = Msg8
Array[6] = Msg9
Array[7] = Msg10
How can i do this? i hope my problem is clear.
Thanks.
© Stack Overflow or respective owner