예제 #1
0
		/// <summary>
		/// Copies the hashtable elements to a NameValuePair array at the specified index.
		/// </summary>
		/// <param name="array">The NameValuePair array that is the destination of the hashtable items.</param>
		/// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
		public void CopyTo(NameValuePair[] array, int arrayIndex)
		{
			var typedArray = array as NameValuePair[];

			if (array == null)
				throw new ArgumentNullException("array");
			if (typedArray == null)
				throw new InvalidCastException("array must be of type NameValuePair[]");
			if (arrayIndex < 0 || (typedArray.Length - arrayIndex) < this.hashTable.Keys.Count)
				throw new ArgumentOutOfRangeException("arrayIndex");

			foreach (object key in this.hashTable.Keys)
			{
				typedArray[arrayIndex++] = new NameValuePair((string)key, (string)this.hashTable[key]);
			}
		}