2
var a = new []{"a"};
var b = new []{"b"};
var c = new []{"c"};

是否可以声明/初始化一个通用列表,在一行中提供上面的三个集合?

var l = new List<string>(a); //fine for one
var l2 = new List<string>(new[] { a, b, c }.SelectMany(x => x)); //this will work but its horrible!
4

1 回答 1

7

怎么样:

var list = a.Concat(b).Concat(c).ToList();
于 2012-05-18T14:08:15.347 回答