Trailing zeroes

Hie huyz. how can i remove trailing 0s for example 1.20 should be 1.2 and 12.00 should be just 12

1 Like

Concert it to double and then back to string

Additionally the Trim function can be used, just pass in β€œ0” and then β€œ.”.

str = 12.00
str.Trim(β€œ0"c).Trim(”."c) = 12

"0"c is shorthand for β€œ0”.ToCharArray

Trim removes any characters on the front or back of the string that match the given character. If you pass Trim with no characters it trims whitespace.

1 Like


Str = β€œ1.20”


Hey @Tapiwa

Use - String.Format("{0:G10}", Decimal.Parse("<your Value>"))


String.Format("{0:G10}", Decimal.Parse("1.20")) // Output - 1.2

String.Format("{0:G10}", Decimal.Parse("12.0000")) // Output - 12



As is this would not convert β€œ12.00” to β€œ12”. It would leave it as β€œ12.”.

1 Like


Will check once.

1 Like

@DanielMitchell @Tapiwa

Try this:


if its 170 it will leave 17

1 Like

This one worked. thanks buddy

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.