Skip to content

How to remove finals 0's of decimal number?

Sergio Fonseca

Asked Apr 17, 2008, 11:18 AM EDT2 answers
Share
LinkedInX

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.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    0

    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);

    0
  • 0

    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.

    0