I’m having issue converting this string to a decimal. I tried to follow the documentation here with no luck: Decimal.TryParse Method
string stringVal = "-(3434343434.00)";
NumberStyles style = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands |
NumberStyles.AllowParentheses | NumberStyles.AllowLeadingSign;
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
decimal value;
bool parseSuccess = decimal.TryParse(stringVal, style, culture, out value);
parseSuccess is returning false.
You have both
()and a-sign in your string. This is incorrect and is why your string doesn’t parse.See the documentations for
AllowParentheses: