How do I shift items in an array in C#?
Posted
by Andy Evans
on Stack Overflow
See other posts from Stack Overflow
or by Andy Evans
Published on 2010-04-20T00:07:53Z
Indexed on
2010/04/20
0:13 UTC
Read the original article
Hit count: 311
Let's say that I have an array of strings like this:
1, 2, 3, 4, 5, 6, 7, 8
and I want to shift the elements of the array such that
- The first element always remains fixed
- Only the remaining elements get shifted like so ...
- The last element in the array becomes the 2nd element and is shifted through the array with each pass.
Pass #1: 1, 2, 3, 4, 5, 6, 7, 8
Pass #2: 1, 8, 2, 3, 4, 5, 6, 7
Pass #3: 1, 7, 8, 2, 3, 4, 5, 6
Pass #4: 1, 6, 7, 8, 2, 3, 4, 5
Any assistance would be greatly appreciated.
© Stack Overflow or respective owner