日期:2014-05-17 浏览次数:20744 次
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var lst = new List<dynamic>
{
new {value1 = 1, value2 = 2},
new {value1 = 3, value2 = 4},
new {value1 = 5, value2 = 6},
};
//我想得到 1-6的序列
var lst2 = lst.Select(v => v.value1).Union(lst.Select(v => v.value2));
//上边这样顺序乱了,我也不想order因为本来是order好的。有没有这样一个方法:集合中每个元素取若干个属性,将这些属性加到结果集中返回的方法?
}
}
}
void Main()
{
var lst = new List<myClass> {
new myClass{value1 = 1, value2 = 2},
new myClass{value1 = 3, value2 = 4},
new myClass{value1 = 5, value2 = 6},