Peek a queue : Queue « Data Structure « C# / CSharp Tutorial






using System;
using System.Collections;
using System.Collections.Specialized;

class MyClass{
   public string MyName="A";   
}

class MainClass
{
  static void Main(string[] args)
  {
    Queue classQueue = new Queue();
    classQueue.Enqueue(new MyClass());
    classQueue.Enqueue(new MyClass());
    classQueue.Enqueue(new MyClass());

    // Peek at first car in Q.
    Console.WriteLine("First in Q is {0}",
      ((MyClass)classQueue.Peek()).MyName);
  }
}
First in Q is A








11.38.Queue
11.38.1.Enqueue and dequeue
11.38.2.Clear a Queue
11.38.3.Peek a queue
11.38.4.Creating a list from a queue
11.38.5.Dequeue and Peek
11.38.6.Queue<(Of <(T>)>) generic class, including the ToArray method.
11.38.7.Queue<(Of <(T>)>) generic class, the Dequeue method.