Which Among The Following Is The Correct Way To Access All The #698
Which among the following is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?</p> <pre><code class="language-csharp" line="1"> Stack st = new Stack(); st.Push(10); st.Push(20); st.Push(-5); st.Push(30); st.Push(6);</code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Reflections, Multithreaded Programming, Collection Classes and Mathematical Functions - Collection Classes - Quiz No.1.
Which among the following is the correct way to access all the elements of the Stack collection created using the C#.NET code snippet given below?
Stack st = new Stack(); st.Push(10); st.Push(20); st.Push(-5); st.Push(30); st.Push(6);
IEnumerable e; e = st.GetEnumerator(); while (e.MoveNext()) Console.WriteLine(e.Current);
IEnumerator e; e = st.GetEnumerator(); while(e.MoveNext()) Console.WriteLine(e.Current);
IEnumerable e; e = st.GetEnumerable(); while(e.MoveNext()) Console.WriteLine(e.Current);
None of the mentioned