GOA - System.Collections.Specialized.StringDictionary

StringDictionary Class


Implements a hashtable with the key strongly typed to be a string rather than an object.

Definition

public class StringDictionary: Object, IEnumerable

Members Table

MethodDescription
AddAdds an entry with the specified key and value into the StringDictionary.
ClearRemoves all entries from the StringDictionary.
ContainsKeyDetermines if the StringDictionary contains a specific key.
ContainsValueDetermines if the StringDictionary contains a specific value.
CopyToCopies the string dictionary values to a one-dimensional Array instance at the specified index.
EqualsOverloaded. Compares two objects to determine if they are equal. (Inherited from Object)
GetEnumeratorReturns an enumerator that can iterate through the StringDictionary.
GetHashCodeServes as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table. (Inherited from Object)
GetTypeGets the Type of the current instance. (Inherited from Object)
ReferenceEqualsDetermines whether the specified Object instances are the same instance. (Inherited from Object)
RemoveRemoves the entry with the specified key from the StringDictionary.
StringDictionaryInitializes a new instance of StringDictionary.
ToStringReturns a String that represents the current Object. (Inherited from Object)
this[]Gets or sets the value associated with the specified key.
PropertyDescription
CountGets the number of key-and-value pairs in the StringDictionary.
IsSynchronizedGets a value indicating whether access to the StringDictionary is synchronized.
KeysGets a collection of keys in the StringDictionary.
SyncRootGets an object that can be used to synchronize access to the StringDictionary.
ValuesGets a collection of values in the StringDictionary.

Inheritance Hierarchy

Object
StringDictionary

Examples

// This sample shows how to implement the StringDictionary class. It also shows some methods and a property.

 

using System.Diagnostics;

using System.Collections;

using System.Collections.Specialized;

 

public class SampleStringDictionary

{

     static void Main()

     {

          // Creates a new StringDictionary.

          StringDictionary myStringDict = new StringDictionary();

 

          // Adds the new entries to the HybridDictionary.

          myStringDict.Add("first","Spring");

          myStringDict.Add("second","Summer");

          myStringDict.Add("third","Autumn");

          myStringDict.Add("fourth","Winter");

 

          // Displaying.

          Debug.WriteLine("The StringDictionary:");

          Debug.WriteLine("\tCount: " + myStringDict.Count);

          Debug.WriteLine("\t" + "KEY \t\tVALUE"); DisplayStringDict(myStringDict);

 

          // Removes an entry from the StringDictionary.

          myStringDict.Remove("fourth");

 

          // Displaying.

          Debug.WriteLine("\nThe StringDictionary after removing:");

          Debug.WriteLine("\tCount: " + myStringDict.Count);

          Debug.WriteLine("\t" + "KEY \t\tVALUE"); DisplayStringDict(myStringDict);

     }

 

     static void DisplayStringDict(StringDictionary myDict)

     {

          foreach (DictionaryEntry dicEntry in myDict)

            Debug.WriteLine("\t" + dicEntry.Key + "\t\t" + dicEntry.Value);

     }

}

 

/*

The output of the sample.

 

The StringDictionary:

     Count: 4

     KEY     VALUE

     fourth  Winter

     third   Autumn

     second  Summer

     first   Spring

 

The StringDictionary after removing:

     Count: 3

     KEY     VALUE

     third   Autumn

     second  Summer

     first   Spring

*/

Class Information

NamespaceSystem.Collections.Specialized
Flash LibrarySystem.scl
Flash Library Version2.0.0.1308
Silverlight LibrarySystem.Windows.Forms.dll



© 2003-2007 NETiKA Technologies. All rights reserved.