In addition to the functional solutions provided (using the static methods on the Enumerable
class), you can pass an array of double
s in the constructor.
var tenDoubles = new List<double>(new double[10]);
This works because the default value of an double
is already 0, and probably performs slightly better.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…