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

来源:互联网 发布:js数组转json 编辑:程序博客网 时间:2024/05/29 07:59
  1. public class Example   
  2. {   
  3.     static void Main()   
  4.     {   
  5.         int[] int_array = { 1, 2, 3 };   
  6.   
  7.         string[] str_array = Array.ConvertAll(int_array, new Converter<intstring>(IntToString));   
  8.   
  9.         foreach (string s in str_array)   
  10.         {   
  11.             Console.WriteLine(s);   
  12.         }   
  13.         Console.Read();   
  14.     }   
  15.   
  16.     public static string IntToString(int i)   
  17.     {   
  18.         return i.ToString();   
  19.     }