C# StringDictionary Add
Description
StringDictionary Add
adds an entry with the specified
key and value into the StringDictionary.
Syntax
StringDictionary.Add
has the following syntax.
public virtual void Add(
string key,
string value
)
Parameters
StringDictionary.Add
has the following parameters.
key
- The key of the entry to add.value
- The value of the entry to add. The value can be null.
Returns
StringDictionary.Add
method returns
Example
The following code example demonstrates how to add and remove elements from a StringDictionary.
/*from w w w . j a v a2 s . c o m*/
using System;
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" );
Console.WriteLine( " KEY VALUE" );
foreach ( DictionaryEntry de in myCol )
Console.WriteLine( " {0,-10} {1}", de.Key, de.Value );
Console.WriteLine();
}
}
The code above generates the following result.