ConvertAll 메서드를 사용하여 정수 배열을 문자열 배열로 변환합니다.
정수 배열 설정 -
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;
이제 Array.ConvertAll() 메서드를 사용하여 정수 배열을 문자열 배열로 변환 -
Array.ConvertAll(intArray, ele => ele.ToString());
전체 코드를 보자 -
예
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));
}
} 출력
15|30|44|50|66