System.Collections.Hashtable.CopyTo C# (CSharp) Method

CopyTo() public method

public CopyTo ( Array array, int arrayIndex ) : void
array Array
arrayIndex int
return void
        public virtual void CopyTo(Array array, int arrayIndex)
        {
            if (array == null)
                throw new ArgumentNullException(nameof(array), SR.ArgumentNull_Array);
            if (array.Rank != 1)
                throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, nameof(array));
            if (arrayIndex < 0)
                throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum);
            if (array.Length - arrayIndex < Count)
                throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall);
            Contract.EndContractBlock();
            CopyEntries(array, arrayIndex);
        }

Usage Example

		protected override void Reload () 
		{
			System.Collections.Hashtable ht = new System.Collections.Hashtable ();
			Photo [] photos = query.Store.Query ((Tag [])null, null, null, null);
			
			foreach (Photo p in photos) {
				if (ht.Contains (p.DirectoryPath)) {
					DirectoryAdaptor.Group group = (DirectoryAdaptor.Group) ht [p.DirectoryPath];
					group.Count += 1;
				} else 
					ht [p.DirectoryPath] = new DirectoryAdaptor.Group ();
			}
			
			Console.WriteLine ("Count = {0}", ht.Count);
			dirs = new System.Collections.DictionaryEntry [ht.Count];
			ht.CopyTo (dirs, 0);
			
			Array.Sort (dirs, new DirectoryAdaptor.Group ());
			Array.Sort (query.Photos, new Photo.CompareDirectory ());
			
			if (!order_ascending) {
				Array.Reverse (dirs);
				Array.Reverse (query.Photos);
			}
			
			if (Changed != null)
				Changed (this);
		}
All Usage Examples Of System.Collections.Hashtable::CopyTo