Home / C# Programming / Collection Classes :: Discussion

Discussion :: Collection Classes

  1. 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);
    

  2. A.
     IEnumerable e;
     e = st.GetEnumerator(); 
     while (e.MoveNext()) 
     Console.WriteLine(e.Current);
    B.
     IEnumerator e;
     e = st.GetEnumerable();
     while (e.MoveNext())
     Console.WriteLine(e.Current);
    C.
     IEnumerator e;
     e = st.GetEnumerator(); 
     while (e.MoveNext())  
     Console.WriteLine(e.Current);
    D.
     IEnumerator e;
     e = Stack.GetEnumerator(); 
     while (e.MoveNext())  
     Console.WriteLine(e.Current);

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    No answer description available for this question.


Be The First To Comment