ArrayList.SetRange(Int32, ICollection) Method is used to copy the elements of a collection over a range of elements in the ArrayList.
public virtual void SetRange (int index, System.Collections.ICollection c);
index: It is a zero-based ArrayList index at which to start copying the elements of c. The type of this parameter is System.Int32.
c: It is an ICollection whose elements to copy to the ArrayList. The collection itself cannot be null, but it can contain elements that are null.
- ArgumentNullException: If the value of c is null.
- NotSupportedException: If the ArrayList is read-only.
- ArgumentOutOfRangeException: If the index is less than zero or [index + number of elements in c] > Count.
Below given are some examples to understand the implementation in a better way:
ArrayList is = This ArrayList is = is ArrayList is = C# ArrayList is = Tutorial ArrayList is = s ArrayList is = G ArrayList is = F ArrayList is = G
String from index number 0 to 6: Hello Welcome to online portal of After SetRange() Method: Hello This is C# tutorial.
- C# | How to copy the entire ArrayList to a one-dimensional Array
- How to create a shallow copy of ArrayList in C#
- C# | Remove a range of elements from the ArrayList
- C# | Reverse the order of the elements in the entire ArrayList or in the specified range
- C# | Getting an enumerator for a range of elements in the ArrayList
- C# | Remove all elements in a collection from a HashSet
- C# | Check if SortedSet and a specified collection share common elements
- C# | Check if HashSet and the specified collection contain the same elements
- C# | Check if a HashSet and a specified collection share common elements
- C# | Check if SortedSet and the specified collection contain the same elements
- C# | Adding the elements of the specified collection to the end of the List
- C# | How to insert the elements of a collection into the List at the specified index
- C# | Remove all elements from the Collection<T>
- C# | Copying the Collection<T> elements to an array
- C# | Get the number of elements actually contained in the ArrayList
- C# | Copying the elements of ArrayList to a new array
- C# | Get or set the number of elements that the ArrayList can contain
- C# | Remove all elements from the ArrayList
- C# | ArrayList whose elements are copies of the specified value
- C# | Sort the elements in the ArrayList
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.
Improved By : Akanksha_Rai