Reputation: 6533
Hey I have the following List
List<int> pos = new List<int>();
for (int i = 0; i < combinedResults.Length; i++)
{
if (combinedResults[i])
{
pos.Add(i);
}
}
But It seems like the last array items are the ones I want first displayed so I was wondering how can I reverse the List ?
Upvotes: 2
Views: 1943
Reputation: 15754
You can use the Reverse method.
Array.Reverse(arranyName);
Upvotes: 0
Reputation: 61727
Use the reverse method
pos.Reverse();
http://msdn.microsoft.com/en-us/library/b0axc2h2.aspx#Y400
Alternatively, loop in reverse, or even better, make sure the data is going in the correct way round and you wont have to maintain all these bits and bobs!
Upvotes: 2
Reputation: 6919
Run the loop in reverse:
for (int i = combinedResults.length-1; i >= 0; i--)
or reverse the list afterwards:
pos.Reverse()
Upvotes: 5