Array.ConvertAll(TInput, Converter<TInput, TOutput>) Method is used to convert an array of one type to an array of another type.
public static TOutput ConvertAll<TInput,TOutput> (TInput array, Converter<TInput,TOutput> converter);
Here, TInput and TOutput is the source array and target array respectively.
array: It is the one-dimensional, zero-based Array to convert to a target type.
converter: It is a Converter that converts each element from one type to another type.
Return Value: This method returns an array of the target type containing the converted elements from the source array.
Exception: This method throws ArgumentNullException if the array is null or converter is null.
Below programs illustrate the use of Array.ConvertAll(TInput, Converter<TInput, TOutput>) Method
Initial Array: 10 20 30 40 Converted Array: 10 20 30 40
Exception Thrown: System.ArgumentNullException
- Converting Enumerated type to String according to the Specified Format in C#
- Converting a String to its Equivalent Byte Array in C#
- C# Program for Converting Hexadecimal String to Integer
- C# | Type.IsAssignableFrom(Type) Method
- C# | Check if an array object is equal to another array object
- C# | Create a Queue from another collection
- C# | Check if a Hashtable is equal to another Hashtable
- C# | Create HashSet from another collection
- C# | How to copy a String into another String
- C#| How to change the size of one-dimensional array
- C# | How to copy the entire ArrayList to a one-dimensional Array
- C# | Type Casting
- C# | Getting the type of the current instance
- C# | Type.GetInterface() Method
- C# | Type.GetMembers() Method
- Type.GetConstructors() Method in C# with Examples
- Dynamic Type in C#
- C# | Type.GetArrayRank() Method
- C# | Getting the Type of the Tuple's Element
- C# | Type.GetField() Method
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.