how to limit character of text with c# scripting?

so there’s a public text,
which is then converted ToDouble,
then used in an equation,
then converted back ToString again.
I want to limit length of that string to 5.
because it shows like 15 digits after decimal point.
which is pointless and also text gets out of its box,
cant find truncate horizontal overflow option.
did some googling and found math.round function,
but it only seems to work with floats and not with doubles or strings.
or may be Im using it incorrectly.
please help.
thank you.

Hello there,

You can do that during the conversion to string, by adding a formatter as an argument to your ToString() call.

If you want to truncate after 5 decimals, use yourValue.ToString("F5");. Of course, you can replace the 5 with another number to truncate at a different point.

I’m also pretty sure this works with both floats and doubles, but you might want to double-check.


I hope that helps!

Cheers,

~LegendBacon