C# Program to convert integer array to string array

CsharpProgrammingServer Side Programming

Use the ConvertAll method to convert integer array to string array.

Set an integer array −

int[] intArray = new int[5];

// Integer array with 5 elements
intArray[0] = 15;
intArray[1] = 30;
intArray[2] = 44;
intArray[3] = 50;
intArray[4] = 66;

Now use Array.ConvertAll() method to convert integer array to string array −

Array.ConvertAll(intArray, ele => ele.ToString());

Let us see the complete code −

Example

 Live Demo

using System;
using System.Text;
public class Demo {
   public static void Main() {
      int[] intArray = new int[5];
      // Integer array with 5 elements
      intArray[0] = 15;
      intArray[1] = 30;
      intArray[2] = 44;
      intArray[3] = 50;
      intArray[4] = 66;
      string[] strArray = Array.ConvertAll(intArray, ele => ele.ToString());
      Console.WriteLine(string.Join("|", strArray));
   }
}

Output

15|30|44|50|66
raja
Published on 04-Sep-2018 15:47:16
Advertisements