public static SqlMoney Parse(string s)
{
// Try parsing the format of '#0.00##' generated by ToString() by using the
// culture invariant NumberFormatInfo as well as the current culture's format
//
decimal d;
SqlMoney money;
const NumberStyles SqlNumberStyle =
NumberStyles.AllowCurrencySymbol |
NumberStyles.AllowDecimalPoint |
NumberStyles.AllowParentheses |
NumberStyles.AllowTrailingSign |
NumberStyles.AllowLeadingSign |
NumberStyles.AllowTrailingWhite |
NumberStyles.AllowLeadingWhite;
if (s == SQLResource.s_nullString)
{
money = SqlMoney.Null;
}
else if (decimal.TryParse(s, SqlNumberStyle, NumberFormatInfo.InvariantInfo, out d))
{
money = new SqlMoney(d);
}
else
{
money = new SqlMoney(decimal.Parse(s, NumberStyles.Currency, NumberFormatInfo.CurrentInfo));
}
return money;
}