且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cast List< int>到List< string>在.NET 2.0

更新时间:2023-11-11 22:34:58

.NET 2.0有 ConvertAll 方法,您可以在其中传递转换函数:

.NET 2.0 has the ConvertAll method where you can pass in a converter function:

List<int> l1 = new List<int>(new int[] { 1,2,3 } );
List<string> l2 = l1.ConvertAll<string>(delegate(int i) { return i.ToString(); });