Home  |  Delphi .net Home  |  System.Collections.Stack  |  Contains Method
  
Contains  
Method  
Returns true if the current Stack contains the given Value
Stack Class
System.Collections NameSpace
CF1.  Function Contains ( Value : Object ) : Boolean;
CF : Methods with this mark are Compact Framework Compatible
Description
The Contains method searches the current Stack for an entry matching Value, returning true if found, otherwise false.
Microsoft MSDN Links
System.Collections
System.Collections.Stack
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.Collections;

var
  MyStack    : System.Collections.Stack;
  Enumerator : IEnumerator;

begin
  // Create our Stack
  MyStack := Stack.Create;

  // Add entries to the stack
  MyStack.Push('First');
  MyStack.Push('Second');
  MyStack.Push('Third');

  // Display the stack
  Enumerator := MyStack.GetEnumerator;
  while enumerator.MoveNext do
    Console.WriteLine(Enumerator.Current.ToString);

  Console.WriteLine;

  if MyStack.Contains('Second')
  then Console.WriteLine('MyStack contains ''Second''')
  else Console.WriteLine('MyStack does not contain ''Second''');

  if MyStack.Contains('Fourth')
  then Console.WriteLine('MyStack contains ''Fourth''')
  else Console.WriteLine('MyStack does not contain ''Fourth''');

  Console.Readline;
end.
   Third
   Second
   First
  
   MyStack contains 'Second'
   MyStack does not contain 'Fourth'
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author