Which of the following is the correct way to access all elements of the Stack collection created using the C#.NET code snippet given below? Stack st = new Stack(); st.Push(11); st.Push(22); st.Push(-53); st.Push(33); st.Push(66);
Correct Answer: IEnumerator e;
e = st.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);
Discussion & Comments