Converting Negative Decimal To String Loses the -
- by coffeeaddict
I'm required to send in a negative myDecimalValue.ToString("C"); The problem is if myDecimalValue is a negative, lets say -39, after conversion I'm getting $39.00 as the string not $39.00. So I'm not sure how to go about this.
This is the utility method that takes in the decimal. If the decimal is negative, I want the ToString to show a negative
public static BasicAmountType CreateBasicAmount(string amount, CurrencyCodeType currencyType)
{
BasicAmountType basicAmount = new BasicAmountType
{
currencyID = currencyType,
Value = amount
};
return basicAmount;
}
I could go either way, a C or F2, all I care is about getting that negative sign intothe string if the incoming decimal is negative. I suppose there's no way to do this unless I check for negativity inside my utility method here. I can't just send a negative number and expect the ToString to work and for the ToSTring to automatically see that the decimal is negative incoming?