O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Queue.Contains Method

Class

System.Collections.Queue

Syntax

                  queuevariable.Contains(obj)
obj (required; any)

The value to search for on the queue

Return Value

Boolean (True or False) indicating whether obj is found in the queue

Description

Returns a Boolean indicating whether a given element whose value is obj is somewhere in the queue

Rules at a Glance

  • obj must correspond exactly to an item in the queue for the method to return True.

  • The method searches the queue sequentially. In other words, its performance is inversely proportional to the number of items in the queue.

Programming Tips and Gotchas

In comparing objects in the queue with obj, the Contains method in turn calls the BCL’s Object.Equals method to perform the comparison. The Equals method returns True if two object instances are the same instance.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required