i have value stored in string format & i want to convert into decimal.
ex:
i have 11.10 stored in string format when i try to convert into decimal it give me 11.1 instead of 11.10 .
I tried it by following way
string getnumber="11.10";
decimal decinum=Convert.ToDecimal(getnumber);
i tried this also
decinum.ToString ("#.##");
but it returns string and i want this in decimal.
what could be the solution for this?
As already commented
11.1is the same value as11.10Will output
trueThe
#formatter in the to string method means an optional digit and will supress if it is zero (and it is valid to suppress – the0in4.05wouldn’t be suppressed). TryAnd you will see the string value of
11.10Ideally you actually want to use something like
At the end of the above code, result will be the decimal you want and “true” will be output to the console.