Try this workaround:
var nf = System.Globalization.CultureInfo.CreateSpecificCulture( "fr-FR" ).NumberFormat;
nf.NumberGroupSeparator = " ";
int.TryParse( "1 036", System.Globalization.NumberStyles.AllowThousands, nf, out int points );
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
we are software publishers, some of which in WPF.
our code encounters a problem with the transition to Windows 11.
The following line:
int.TryParse("1 036", System.Globalization.NumberStyles.AllowThousands, System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR"), out int points)
correct under Windows 10 and earlier returns 1036, for the points variable.
On the other hand under Windows 11, it returns "false".
After several searches, it turns out that the thousand separator character present by default for the French language has changed?!
This is really problematic, because we can't ask all of our Windows 11 users to change their regional settings.
Do you have a solution to propose or a corrective update of this point planned?
Thanks in advance.
Best regards,
Thomas
Try this workaround:
var nf = System.Globalization.CultureInfo.CreateSpecificCulture( "fr-FR" ).NumberFormat;
nf.NumberGroupSeparator = " ";
int.TryParse( "1 036", System.Globalization.NumberStyles.AllowThousands, nf, out int points );
@Viorel Thanks for your workaround which will definitely work, however, it will cause me to change dozens of lines of code in our apps, maybe even hundreds... (we do a lot of math) and I'd rather the solution come from source ;)
But thanks again for your useful contribution!