C# 实现 int[]到string[]的转换方法 Array.ConvertAll

01.using System;   

02.using System.Collections.Generic;   

03.  

04.//int[]到string[]的转换   

05.public class Example   

06.{   

07.    static void Main()   

08.    {   

09.        int[] int_array = { 1, 2, 3 };   

10.  

11.        string[] str_array = Array.ConvertAll(int_array, new Converter<int, string>(IntToString));   

12.  

13.        foreach (string s in str_array)   

14.        {   

15.            Console.WriteLine(s);   

16.        }   

17.        Console.Read();   

18.    }   

19.  

20.    public static string IntToString(int i)   

21.    {   

22.        return i.ToString();   

23.    }   

24.}  

 

你可能感兴趣的:(convert)