Skip to content
David Cumps
Exam 70-536 study notes

NameValueCollection Class

Part of my 2008 study notes for exam 70-536 (.NET Framework 2.0).

Overview

  • Acts like a StringDictionary which can store multiple values under the same key.
  • Values can be retrieved by key or index.

Good practice

Examples

Simple Usage

NameValueCollection valueCollection = new NameValueCollection();
 
valueCollection.Add("Key1", "Value1");
valueCollection.Add("Key1", "Value2");
valueCollection.Add("Key2", "Value3");
 
foreach (string s in valueCollection.Keys)
{
    Console.WriteLine(valueCollection[s]);
}

You May Also Like