Extend double.Parse to interpret Percent values - by omjbe

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


21
0
Sign in
to vote
ID 651185 Comments
Status Closed Workarounds
Type Suggestion Repros 1
Opened 3/13/2011 2:03:48 PM
Access Restriction Public

Description

The double.Parse method allows us to parse currency values:
var c = double.Parse("100.00$", NumberStyles.Currency, CultureInfo.CurrentCulture.NumberFormat);

This call takes care about the localization settings of the operating system. I would like the same feature for percent values. E.g.:

var p = double.Parse("100.00%", NumberStyles.Percent, CultureInfo.CurrentCulture.NumberFormat);

Lot solutions are found in the internet on how to parse percent values but most of them don't work right when the application is localized. Therefore, the .NET Framework should provide a correct solution in the BCL.
Sign in to post a comment.
Posted by Marco Guignard on 4/24/2012 at 5:44 AM
I Agree. We have features for formatting with percent a number to string but nothing to parse it back !
Posted by Josh [MSFT] on 6/20/2011 at 9:50 AM
Thank you for the feature suggestions for NumberStyles and numeric parsing. We will record the request and number of up-votes and consider the change for the next major release of the .NET Framework.
Posted by ILa.MSDN on 6/17/2011 at 1:39 AM
Good idea ...and while you are at it, please also consider fractions of all available NumberStyles.
Posted by Andrea Antonangeli on 3/17/2011 at 11:10 AM
Agree. I was surprised not to find such an easy and common conversion
Posted by BlindSniper45 on 3/14/2011 at 7:17 AM
I agree. We can work with % sings in the visual studio IDE Why can't we parse them from strings ? It doesn't make sense.
Posted by Microsoft on 3/13/2011 at 7:11 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by Microsoft on 3/13/2011 at 7:11 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by Kevininstructor on 3/13/2011 at 6:02 PM
I believe that should be included too
Posted by dbasnett on 3/13/2011 at 4:46 PM
Decimal as well.
Posted by dbasnett on 3/13/2011 at 4:43 PM
I agree. I was surprised that Parse / TryParse didn't already.