Hello How do i Convert a negative value that's in bracket format to double. Currently I have this.
Payment.Text = Calc_Payment().ToString("#,##0.00;(#,##0.00)");
That converts the payment to Bracket format But I want to do the reverse. String in bracket format to Double. If anyone could help please.
Please try the following:
// using System.Globalization
double d = double.Parse("(1,000.90)", NumberStyles.AllowParentheses |
NumberStyles.AllowThousands |
NumberStyles.AllowDecimalPoint)
/* d = -1000.9 */
Ref. Double.Parse Method (String, NumberStyles); NumberStyles Enumeration
NOTE: Money values are better handled by the 'decimal' type. From the documentation:
Compared to floating-point types, the decimal type has more precision and a smaller range, which makes it appropriate for financial and monetary calculations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With