Is there something that can read a double from a known start position in a string?
I want to avoid the allocation in double.Parse(s.Substring(...))
Also the split is nontrivial with numberstyles & cultures.
It feels like there must be something in the framework but I cannot find it.
The signature would look like:
var d = double.Parse(text, startPos, numberstyles, formatProvider, out endPos);
This is what I wrote, yes it allocates:
Sadly it allocates a substring. IIRC the next version of C# will have cheaper allocations for substrings, until then all the nasty optimized code is wasted :) It handles the test cases i could think of. It reads as long as it is a valid double. The problem is impossible to solve for the general case but it works for what I need it to.
Perhaps it is useful for someone.