Assuming that MyList
is of type List<T>
and MyStack
is of type Stack<T>
:
List<T>
defines a method named Reverse
which reverses the order of the elements in the List [...]
But Stack<T>
does not define such a method.
There is an extension method Enumerable.Reverse<T>
that returns the elements in reversed order.
So you could try this:
MyStack = new Stack ( MyStack.Reverse() );
MSDN:
Update
As @Dennis_E mentioned in his answer and comment, calling above line of code would reverse the stack twice - meaning that MyStack will stay the same... So the correct answer is
MyStack = new Stack(MyStack);