I would like to ask how i should add the minus sign front of a decimal value.
i want the user to add e.g. 100 and behind the scenes to convert it in -100
thank you.
I would like to ask how i should add the minus sign front of a decimal value.
i want the user to add e.g. 100 and behind the scenes to convert it in -100
thank you.
If it's a decimal, convert it to a decimal, and then multiple by literal -1m
. Or what Pavel said.
I'm not sure about whether I got your question right. Are you asking how to negate a number?
decimal negated = -1.0M * userInputValue;
Is that what you are asking for? Or are you asking for automatically formatting the number as if the user had entered a negative number? In that case you could do:
string display = String.Format("-{0}", userInputValue);
I'm still not sure whether I get what you want...