C# Programming - Collection Classes - Discussion

Discussion Forum : Collection Classes - General Questions (Q.No. 15)
15.
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);
IEnumerable e;
e = st.GetEnumerator(); 
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerator e;
e = st.GetEnumerable(); 
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerator e;
e = st.GetEnumerator(); 
while (e.MoveNext()) 
Console.WriteLine(e.Current);
IEnumerator e;
e = Stack.GetEnumerator(); 
while (e.MoveNext()) 
Console.WriteLine(e.Current);
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Daobin said:   6 years ago
@Ramila.

It's not the same. Check the first word: IEnumerable / IEnumerator.
(1)

Ramila said:   8 years ago
Both A and C are same then how can decide C is correct answer?

Post your comments here:

Your comments will be displayed after verification.