C# StringDictionary ContainsKey

Description

StringDictionary ContainsKey determines if the StringDictionary contains a specific key.

Syntax

StringDictionary.ContainsKey has the following syntax.


public virtual bool ContainsKey(
  string key
)

Parameters

StringDictionary.ContainsKey has the following parameters.

  • key - The key to locate in the StringDictionary.

Returns

StringDictionary.ContainsKey method returns true if the StringDictionary contains an entry with the specified key; otherwise, false.

Example


using System;/*  ww  w. j  av a2 s. co  m*/
using System.Collections;
using System.Collections.Specialized;

public class SamplesStringDictionary  {

   public static void Main()  {
      StringDictionary myCol = new StringDictionary();
      myCol.Add( "red", "rojo" );
      myCol.Add( "green", "verde" );
      myCol.Add( "blue", "azul" );

      if ( myCol.ContainsKey( "red" ) )
         Console.WriteLine( "The collection contains the key \"red\"." );
      else
         Console.WriteLine( "The collection does not contain the key \"red\"." );

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Collections.Specialized »




BitVector32
HybridDictionary
ListDictionary
OrderedDictionary
StringCollection
StringDictionary
StringEnumerator