How to use Array.ConvertAll to convert an array of one type to an array of another type

62 Points
26 Posts


I am trying to convert an array of one object type to array of another object type. I got success by using for loop. But now I have Array.ConvertAll and want to use it. How can I do it usning Array.ConvertAll.

Thanks in advance.

Views: 8165
Total Answered: 1
Total Marked As Answer: 1
Posted On: 12-Apr-2016 19:38

Share:   fb twitter linkedin
Rahul Maurya
Rahul M...
1172 Points
211 Posts


Array.ConvertAll<TInput, TOutput> Method (TInput[], Converter<TInput, TOutput>)

It converts an array of one type to an array of another type.


In the following example we have two class InputClass and OutputClass , one method ConvertArrayObject that will convert array of InputClass to array of OutputClass. 

public class InputClass {
public int id { get; set; }
public string name { get; set; }
public class OutputClass {
public string myId { get; set; }
public string myName { get; set; }
public OutputClass[] ConvertArrayObject(InputClass[] inputArray) {
System.Array.ConvertAll<InputClass, OutputClass>(inputArray, (elem) => {
return new OutputClass {
myId =,
myName =


Posted On: 14-Apr-2016 00:38
 Log In to Chat