发布于 2008-09-04 23:16:00
.NET 2.0提供了ConvertAll
方法,您可以在该方法中传入转换器函数:
List<int> l1 = new List<int>(new int[] { 1, 2, 3 } );
List<string> l2 = l1.ConvertAll<string>(delegate(int i) { return i.ToString(); });
发布于 2010-03-03 06:09:44
2010年更新
List<int> l1 = new List<int>(new int[] { 1,2,3 } );
List<string> l2 = l1.ConvertAll<string>(x => x.ToString());
发布于 2013-03-03 02:33:26
您可以使用:
List<int> items = new List<int>(new int[] { 1,2,3 } );
List<string> s = (from i in items select i.ToString()).ToList();
https://stackoverflow.com/questions/44942
复制相似问题