score:48

Accepted answer
array.convertall(sarray.split(','), double.parse);

unlike linq's .toarray(), this pre-allocates a correctly-sized array and doesn't do any resizing.
this should be indistinguishable from a hand-rolled loop.

score:14

when i used:

double[] doubles = array.convertall(sarray.split(','), double.parse);

i got this error:

the type arguments for method 'system.array.convertall(tinput[], system.converter)' cannot be inferred from the usage. try specifying the type arguments explicitly.

but it worked when i did this:

double[] doubles = array.convertall(sarray.split(','), new converter<string, double>(double.parse));

Related Query

More Query from same tag