C# Stack Contains

Description

Stack Contains determines whether an element is in the Stack.

Syntax

Stack.Contains has the following syntax.


public virtual bool Contains(
  Object obj
)

Parameters

Stack.Contains has the following parameters.

  • obj - The Object to locate in the Stack. The value can be null.

Returns

Stack.Contains method returns true, if obj is found in the Stack; otherwise, false.

Example


using System;/* w  w  w . j a  va 2  s .  c  o  m*/
using System.Collections;

public class SamplesStack  {

    public static void Main()  {

       Stack myStack = new Stack();
       myStack.Push( "A" );
       myStack.Push( "B" );

       Console.WriteLine(myStack.Contains("A"));

    }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections »




ArrayList
BitArray
Comparer
Hashtable
Queue
SortedList
Stack