Open universorum opened 2 months ago
Tagging subscribers to this area: @dotnet/area-system-numerics See info in area-owners.md if you want to be subscribed.
The Convert pattern is deprecated for a long time. But we do need a better way to convert with different bases.
@huoyaoyuan Out of curiosity, deprecated in favor of what?
deprecated in favor of what?
Parse
methods on each type, like int.Parse
and int.TryParse
.
But we do need a better way to convert with different bases.
This largely already exists. Convert only supports a fixed set of bases today: 2
, 8
, 10
, and 16
All of these except octal (8
) are supported via passing in the relevant NumberStyles
options to the int.Parse
and related APIs nowadays
All of these except octal (
8
) are supported via passing in the relevantNumberStyles
options to theint.Parse
and related APIs nowadays
Yes, but it's still gap we can improve: add octal options to NumberStyles
, and dispatch NumberStyles
based on numeric base values.
and dispatch NumberStyles based on numeric base values
I don't think I've ever seen a meaningful example where fromBase wasn't a constant. What's the scenario for this?
Duplicate of #61397?
Background and motivation
Consider the string
Value: 0xff
. If the API only accept the string, we will need create the new string instance bystr[^2..]
.In the API inside, many method like
ParseNumbers.StringToInt
(internal class) andint.Parse
already accpet theReadOnlySpan<char>
type. Why we cannot pass theReadOnlySpan<char>
to API to avoid alloc?also #22848
API Proposal
API Usage
Alternative Designs
No response
Risks
No response