public void Remove(string name) { // Attempt to locate the name/value pair in the internal ArrayList HeaderValuePair valuePair = HeaderValuePairForHeader(name); // If the name/value pair exists, remove it from the ArrayList if (valuePair != null) { headerNameValuePairs.Remove(valuePair); } }
public string this[string name] { get { // Attempt to locate the name/value pair in the internal ArrayList HeaderValuePair valuePair = HeaderValuePairForHeader(name); // If the name/value pair was found, return the value if (valuePair != null) { return(valuePair.Value); } return(null); } set { Set(name, value); } }
public void Set(string name, string value) { // If the value is null or empty, remove the item from the list if (value == null || value == string.Empty) { Remove(name); return; } // Attempt to locate the name/value pair in the internal ArrayList HeaderValuePair valuePair = HeaderValuePairForHeader(name); // If the key already exists, update its value if (valuePair != null) { valuePair.Value = value; } // Otherwise, add a new name/value pair else { headerNameValuePairs.Add(new HeaderValuePair(name, value)); } }