adplus-dvertising
frame-decoration

Question

The correct code to access all the elements of the queue collection created using the C#.NET code snippets given below is?
Queue q = new Queue();
q.Enqueue("Harsh");
q.Enqueue('a');
q.Enqueue(false);
q.Enqueue(70);
q.Enqueue(8.5);

a.

IEnumerator e;
e = q.GetEnumerator();
while(e.MoveNext())
Console.WriteLine(e.Current);

b.

IEnumerable e;
e = q.GetEnumerator();
while(e.MoveNext())

c.

IEnumerable e
e = q.GetEnumerable();
while(e.MoveNext())
Console.WriteLine(e.Current);

d.

All of the mentioned

Answer: (a).IEnumerator e;
e = q.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. The correct code to access all the elements of the queue collection created using the C#.NET code snippets given below is?