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

A. <pre><code class="csharp">IEnumerable e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
B. <pre><code class="csharp">IEnumerator e; e = st.GetEnumerable(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
C. <pre><code class="csharp">IEnumerator e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
D. <pre><code class="csharp">IEnumerator e; e = Stack.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>
Answer» D. <pre><code class="csharp">IEnumerator e; e = Stack.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);</code></pre>


Discussion

No Comment Found

Related MCQs