I'm using decimal to make and Physic calculator but I've noticed it keeps the finals 0's without taking out 0's in midle or being or before the "," of the result. For example:
275 M/s to KM/h
The Result is 990.
But the program shows 990,0.
I want make it show 990 instead of 990,0.
How to remove finals 0's of decimal number?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Niradhip ChakrabortyRank #428 · 5.8K pointsPosted Apr 17, 2008, 12:23 PM EDT
U want 990 instead of 990,0.
So u want to remove last two characters,i.e " ," and "0". Take a string say msg and assign the value into it and then use the following code
string msg =null;(assign the value here)
string msgnew=msg.Substring(0,msg.Length-2);
Sergio Fonseca40 pointsPosted Apr 17, 2008, 2:24 PM EDT
I need it to detect how much length it gotta remova. I think I know a way on how to do so now. I'll try with this one I just though:
while (string.EndsWith == "0")
{
string.Length = string.Length - 1;
}
if (string.EndsWith == ",")
string.Length = string.Length - 1;
Thank you for your help.