adplus-dvertising
frame-decoration

Question

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.

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

Posted under C# programming

Answer: (c).IEnumerator e;
e = st.GetEnumerator();
while (e.MoveNext())
Console.WriteLine(e.Current);

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. 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?

Similar Questions

Discover Related MCQs

Q. Which of the following statements are correct about the Collection Classes available in Framework Class Library?

Q. Which among the following is not the ordered collection class?

Q. Which among the following is not an interface declared in System.Collection namespace?

Q. Which among the following is the correct way to find out the number of elements currently present in an ArrayListCollection called arr?

Q. Which is the correct statement about an ArrayList collection that implements the IEnumerable interface?

Q. Which statements among the following are correct about the Collection Classes available in Framework Class Library?

Q. Among the given collections which one is I/O index based?

Q. Which among the given statements are correct about the Stack collection?

Q. A HashTable t maintains a collection of names of states and capital city of each state.Which among the following finds out whether “New delhi” state is present in the collection or not?

Q. In which of the following collections is the I/O based on a key?

Q. The wrong statements about a HashTable collection are?

Q. Which of these classes contains only floating point functions?

Q. What is the value of double constant ‘E’ defined in Math class?

Q. Which among the given classes provides types of rounding functions?

Q. Which of these methods is a rounding function of Math class?

Q. Which of these method returns a smallest whole number greater than or equal to variable X?

Q. Which of these methods return a largest whole number less than or equal to variable X?

Q. Which of the following functions return absolute value of a variable?