System.Collections.SortedList.Add C# (CSharp) Method

Add() public method

public Add ( Object key, Object value ) : void
key Object
value Object
return void
        public virtual void Add(Object key, Object value)
        {
            if (key == null) throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key);
            Contract.EndContractBlock();
            int i = Array.BinarySearch(_keys, 0, _size, key, _comparer);
            if (i >= 0)
                throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate__, GetKey(i), key));
            Insert(~i, key, value);
        }

Same methods

SortedList::Add ( object key, object value ) : void

Usage Example

 private void GatherNamespaceToRender(string nsPrefix, SortedList nsListToRender, Hashtable nsLocallyDeclared)
 {
     int num;
     foreach (object obj2 in nsListToRender.GetKeyList())
     {
         if (Utils.HasNamespacePrefix((XmlAttribute) obj2, nsPrefix))
         {
             return;
         }
     }
     XmlAttribute a = (XmlAttribute) nsLocallyDeclared[nsPrefix];
     XmlAttribute nearestRenderedNamespaceWithMatchingPrefix = base.GetNearestRenderedNamespaceWithMatchingPrefix(nsPrefix, out num);
     if (a != null)
     {
         if (Utils.IsNonRedundantNamespaceDecl(a, nearestRenderedNamespaceWithMatchingPrefix))
         {
             nsLocallyDeclared.Remove(nsPrefix);
             nsListToRender.Add(a, null);
         }
     }
     else
     {
         int num2;
         XmlAttribute nearestUnrenderedNamespaceWithMatchingPrefix = base.GetNearestUnrenderedNamespaceWithMatchingPrefix(nsPrefix, out num2);
         if (((nearestUnrenderedNamespaceWithMatchingPrefix != null) && (num2 > num)) && Utils.IsNonRedundantNamespaceDecl(nearestUnrenderedNamespaceWithMatchingPrefix, nearestRenderedNamespaceWithMatchingPrefix))
         {
             nsListToRender.Add(nearestUnrenderedNamespaceWithMatchingPrefix, null);
         }
     }
 }
All Usage Examples Of System.Collections.SortedList::Add