Groups | Blog | Home
all groups > dotnet sdk > may 2006 >

dotnet sdk : parse a currency, parse a number


David Thielen
5/15/2006 4:12:02 PM
Hi;

Is there an easy way to parse $1,234.56 and/or 1,234.56? I assume I have to
pass a locale to whatever handles this.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
stcheng NO[at]SPAM online.microsoft.com
5/16/2006 1:30:34 AM
Hi Dave,

As for currency or decimal value, we can use the System.Decimal.Parse
method(in C# just decimal.Parse), this method ake a string as the first
parameter, and we can provide an additional CultureInfo instance to specify
the locale(region) info when parsing decimal value of different regions.
Also, for the string passed into this method, it can not contain currency
sign (like $, €). e.g:

==================
CultureInfo ci = new CultureInfo("de-DE");

string dstr = null;

dstr = "1.234,56";

decimal d = decimal.Parse(dstr, ci);

Response.Write("<br/>decimal: " + d);
=========================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


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



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
AddThis Social Bookmark Button