HybridDictionary.CopyTo(Array, Int32) method is used to copy the HybridDictionary entries to a one-dimensional Array instance at the specified index.
public void CopyTo (Array array, int index);
array : The one-dimensional Array that is the destination of the DictionaryEntry objects copied from HybridDictionary. The Array must have zero-based indexing.
index : The zero-based index in array at which copying begins.
- ArgumentNullException : If the array is null.
- ArgumentOutOfRangeException : If the index is less than zero.
- InvalidCastException : If the type of the source HybridDictionary cannot be cast automatically to the type of the destination array.
- ArgumentException : If array is multidimensional OR the number of elements in the source HybridDictionary is greater than the available space from arrayIndex to the end of the destination array.
Below programs illustrate the use of HybridDictionary.CopyTo(Array, Int32) method:
A --> Apple B --> Banana C --> Cat D --> Dog E --> Elephant F --> Fish
System.ArgumentOutOfRangeException: Index is less than zero.
Parameter name: index
- The elements are copied to the Array in the same order in which the enumerator iterates through the HybridDictionary.
- To copy only the keys in the HybridDictionary, use HybridDictionary.Keys.CopyTo.
- To copy only the values in the HybridDictionary, use HybridDictionary.Values.CopyTo.
- This method is an O(n) operation, where n is Count.
- C# | Copying the Hashtable elements to an Array Instance
- C# | Removing all entries from HybridDictionary
- Copying the Queue elements to 1-D Array in C#
- C# | Copying the Collection<T> elements to an array
- C# | Copying the elements of ArrayList to a new array
- C# | Copying BitArray elements to an Array
- C# | Copying the SortedList elements to an Array Object
- C# | Copying the entire ArrayList to 1-D Array starting at the specified index
- C# | Copy ListDictionary to Array instance at the specified index
- C# | Copy OrderedDictionary elements to Array instance at the specified index
- C# | Gets or sets the value in HybridDictionary with specified key
- C# | HybridDictionary Class
- C# | Adding the specified key and value into HybridDictionary
- C# | Check if HybridDictionary is read only
- C# | Get an ICollection containing the keys in HybridDictionary
- C# | Check the HybridDictionary for a specific key
- C# | Removing the specified key entry from HybridDictionary
- How to get Synchronize access to the HybridDictionary in C#
- C# | Get an ICollection containing the values in HybridDictionary
- C# | Get an enumerator that iterates through the HybridDictionary
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.