转换列表<&诠释GT;列出<长>
问题描述:
如何转换列表< INT>
到列表<长>
在C#
答
这样的:
List<long> longs = ints.ConvertAll(i => (long)i);
这使用C#3.0 lambda表达式;如果你在VS 2005中使用C#2.0中,你需要写 p>
This uses C# 3.0 lambda expressions; if you're using C# 2.0 in VS 2005, you'll need to write
List<long> longs = ints.ConvertAll<int, long>(
delegate(int i) { return (long)i; }
);