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

GetKey() public method

public GetKey ( int index ) : Object
index int
return Object
        public virtual Object GetKey(int index)
        {
            if (index < 0 || index >= Count) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index);
            Contract.EndContractBlock();
            return _keys[index];
        }

Same methods

SortedList::GetKey ( int index ) : object

Usage Example

Example #1
0
        /// <summary>
        /// Returns a portion of the list whose keys are greater that the lowerLimit parameter less than the upperLimit parameter.
        /// </summary>
        /// <param name="l">The list where the portion will be extracted.</param>
        /// <param name="limit">The start element of the portion to extract.</param>
        /// <param name="limit">The end element of the portion to extract.</param>
        /// <returns>The portion of the collection.</returns>
        public static System.Collections.SortedList SubMap(System.Collections.SortedList list, System.Object lowerLimit, System.Object upperLimit)
        {
            System.Collections.Comparer   comparer = System.Collections.Comparer.Default;
            System.Collections.SortedList newList  = new System.Collections.SortedList();

            if (list != null)
            {
                if ((list.Count > 0) && (!(lowerLimit.Equals(upperLimit))))
                {
                    int index = 0;
                    while (comparer.Compare(list.GetKey(index), lowerLimit) < 0)
                    {
                        index++;
                    }

                    for (; index < list.Count; index++)
                    {
                        if (comparer.Compare(list.GetKey(index), upperLimit) >= 0)
                        {
                            break;
                        }

                        newList.Add(list.GetKey(index), list[list.GetKey(index)]);
                    }
                }
            }

            return(newList);
        }
All Usage Examples Of System.Collections.SortedList::GetKey