Returns the object at the head of the Queue without removing it.
[Visual Basic] Overridable Public Function Peek() As Object [C#] public virtual object Peek(); [C++] public: virtual Object* Peek(); [JScript] public function Peek() : Object;
The object at the head of the Queue, if the Queue is not empty; otherwise, a null reference (in Visual Basic Nothing).
Exception Type | Condition |
---|---|
InvalidOperationException | The Queue is empty. |
This method can be overridden by a derived class.
This method is similar to the Dequeue method, but Peek does not modify the Queue.
Queue Class | Queue Members | System.Collections Namespace | Enqueue | Dequeue