PC Review


Reply
Thread Tools Rate Thread

CultureInfo and Decimal point.

 
 
Hector
Guest
Posts: n/a
 
      28th Dec 2006
Hi,

My application supports different languages, and i have a problem with the
decimals:
In this application, i receive datas like "10.528".
When i use CurrentCulture = "en-US", no problem.
But with "fr-FR" for example, there's a bug.

Of course, one way to solve this problem is to test if the current language
is "fr-FR" and then make a Replace(",",".").

But i guess there's should be a better way, no ?

Thanks.


 
Reply With Quote
 
 
 
 
Rad [Visual C# MVP]
Guest
Posts: n/a
 
      28th Dec 2006
On Thu, 28 Dec 2006 14:37:15 +0100, Hector wrote:

> fr-FR


Hey Hector.

Here's a small example of one way to solve the problem:

//
// Assume the application is running under
// the French language
//
Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("fr-FR");
//
// Get a string value with the number
//
string val = "10.90";
//
// Parse the string as a decimal using the
// english (US) culture
//
Decimal data = Decimal.Parse(val,
new System.Globalization.CultureInfo("en-US"));
//
// Write the value to screen
// Should be 10,90
//
Console.WriteLine(data);

--
Bits.Bytes
http://bytes.thinkersroom.com
 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      29th Dec 2006
Hi Hector,

I agree with David that you can specify the en-US culture info as format
provider. However, in my opinion, if the machine's locale setting has been
set to fr-FR, it will be better for us to observe the machine setting,
since the user to this machine might be used to take comma as decimal point.

If there is anything unclear, please feel free to let me know.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      2nd Jan 2007
Hi Hector,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Decimal.Parse and CultureInfo =?Utf-8?B?T2xpdmllciBHSUw=?= Microsoft ASP .NET 8 23rd May 2007 02:41 PM
Converting 2-place decimal value to floating point decimal number with leading zero Kermit Piper Microsoft Excel Misc 3 18th Mar 2006 06:20 PM
CultureInfo, both '.' and ',' as decimal separator? =?Utf-8?B?UGV0ZXIgRXJpa3Nvbg==?= Microsoft Dot NET Framework Forms 1 3rd Aug 2005 09:06 AM
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. =?Utf-8?B?U1VLWUtJVFRZ?= Microsoft Excel Misc 3 6th Jul 2005 01:50 PM
Formatting with Decimal.ToString() ... CultureInfo and DigitGrouping... G.Ashok Microsoft VB .NET 8 4th Oct 2004 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 AM.