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));
Source: stackoverflow.com
Related Query
- Fastest way to convert string array to double array?
- Convert 2D array to string in C#, looking for most elegant way
- Is there a way to convert a string array into char array using LINQ?
- List or Array of String Contain specific word in Html Source Code
- Convert string to int array using LINQ
- Fastest way to search in a string collection
- Shortest method to convert an array to a string in c#/LINQ
- Fastest way to convert List<int> to List<int?>
- Best way to convert Dictionary<string, string> into single aggregate String representation?
- Convert linq query to string array - C#
- How to Convert the value in DataTable into a string array in c#
- Convert Array of Strings to Comma Separated String with additional concatenation
- best way to convert collection to string
- Convert string array to custom object list using linq
- Easiest way to convert list to a comma separated string by a Specific Property?
- Fastest Conversion of Array of Guid to String and Back?
- Efficient way to unindent lines of code stored in a string
- C# loopless way to split string into multidimensional array or jagged array
- How to convert a list of ints to a string array in Linq?
- C# - Convert delimited string array w/ duplicates to dictionary using LINQ
- How to convert string array to string in Linq to entities?
- Convert delimited string to array and group using LINQ in C#
- Fast way to convert a string to a struct
- Use linq to convert string to 3D array
- how do i convert Dictionary string string to array of key value pair of string and string using linq and c#
- how to convert nested array of arrays into comma separated string
- Fastest way to get values from 2d array
- How to convert a list of anonymous object to string array using linq for return using Json Result in ASP.NET MVC
- Fastest way to convert NVARCHAR value to XML
- Fastest way to search an array for matches in another array
More Query from same tag
- Getting values from JSON objects using LINQ
- Convert SQL Query into C#
- Subsonic 3 LINQ Projection issue, fixed or no?
- Convert xml string from entity framework query to xdocument
- How do I select multiple tables in LINQ?
- How can I call ToLower() on each string in a collection using LINQ?
- Is an object still connected to a list after FirstOrDefault?
- How can I query using Entity Framework with an alpha-numeric comparison?
- What is a good way to find the latest created file in a folder in c#?
- How to return numberOfMessages per user using Linq
- LINQ query to merge multiple rows
- Using IEqualityComparer GetHashCode with a tolerance
- How to make generic linq expression even more "generic"
- How can i use Linq / Linq to Sql to do this?
- Linq Categories and SubCategories
- DropDownList selectedvalue and tables
- How Is It Possible For a Group By To Return a Duplicate Key?
- Subquery in Where Clause of LINQ statement
- Search XML doc with LINQ
- method with a return type of "Expression"
- MVC4 Linq Query Optimisation
- How can I create an Lambda Expression for Linq in the Where clause for two tables after the Join?
- Populate Observable Collection from LINQ query results
- How to query and calculate dates in the where clause of a LINQ statement?
- Find a nice Linq solution to ensure defined accuracy
- Use linq to return a selection of data from list<t>
- Convert IGrouping to IList<Class>
- Retrieving an XElement from Dictionary object (<string, List<XElement>>) which contains List of XElements using Linq
- Inconsistent LINQ Results comparing DataTables
- dynamically select fields in linq