[ Team LiB ] Previous Section Next Section

NameValueCollectionCF 1.0, ECMA 1.0, serializable

System.Collections.Specialized (system.dll)class

This class is a collection of keys and associated values composed of strings in which a single key may have multiple values associated with it. A multivalued entry is stored as a comma-separated list of the string values. Use the Add( ) method to append new values to existing values of a key. Using Set( ) or setting the value by key name overwrites the existing value. You can use a string containing a comma-separated list to assign multiple values to a key.

The GetValues( ) method returns a string array containing all the values of the specified key (or index). An example of how this class is used is System.Net.WebHeaderCollection, which derives from it. A WebHeaderCollection contains the collection of various HTTP header names as key strings and their values. HTTP headers such as Accept: often have multiple values (for example, MIME types for Accept).

public class NameValueCollection : NameObjectCollectionBase {
// Public Constructors
   public NameValueCollection( );
   public NameValueCollection(System.Collections.IHashCodeProvider hashProvider,
        System.Collections.IComparer comparer);
   public NameValueCollection(int capacity);
   public NameValueCollection(int capacity, System.Collections.IHashCodeProvider hashProvider, 
        System.Collections.IComparer comparer);
   public NameValueCollection(int capacity, NameValueCollection col);
   public NameValueCollection(NameValueCollection col);
// Protected Constructors
   protected NameValueCollection(System.Runtime.Serialization.SerializationInfo info, 
        System.Runtime.Serialization.StreamingContext context);
// Public Instance Properties
   public virtual string[ ] AllKeys{get; }
   public string this[int index]{get; }
   public string this[string name]{set; get; }
// Public Instance Methods
   public void Add(NameValueCollection c);
   public virtual void Add(string name, string value);
   public void Clear( );
   public void CopyTo(Array dest, int index);        
// implements ICollection
   public virtual string Get(int index);
   public virtual string Get(string name);
   public virtual string GetKey(int index);
   public virtual string[ ] GetValues(int index);
   public virtual string[ ] GetValues(string name);
   public bool HasKeys( );
   public virtual void Remove(string name);
   public virtual void Set(string name, string value);
// Protected Instance Methods
   protected void InvalidateCachedArrays( );
}

Hierarchy

System.Object NameObjectCollectionBase(System.Collections.ICollection, System.Collections.IEnumerable, System.Runtime.Serialization.ISerializable, System.Runtime.Serialization.IDeserializationCallback) NameValueCollection

Subclasses

System.Net.WebHeaderCollection

Returned By

System.Net.WebClient.QueryString

Passed To

System.Net.WebClient.{QueryString, UploadValues( )}

    [ Team LiB ] Previous Section Next Section