how to convert string ($23.25) to Decimal -$23.25 in selenium with C# -
i using xpath string shown in format ($23.25) should converted -$23.25. have tried:
decimal.parse(string, numberstyles.allowcurrencysymbol | numberstyles.number);
but not returning negative value.
instead of numberstyles.number
use numberstyles.allowparentheses
.
var balance = decimal.parse("($23.25)", numberstyles.currency | numberstyles.allowparentheses); // -23.25
if format "-$23.25", here how :
balance.tostring("$0.00") // -$23.25
Comments
Post a Comment