Main Site Documentation

No Trim.Remove?


#1

I am looking to convert a double into a string of a specific length.
MathEx.Round Returns a double from an input of a long.
But I need the char’s string from the double to be less than 15 char’s to print properly in a display.
I have seen that Trim.Remove is not available.

Any idea’s?


#2

hello,

Not sure I got what you want to do…
with a string, Trim is to remove space and Remove to del a specific char or set of char.

to manage the string size:

 string myString = "12.65365346534653465987987999";
            if (myString.Length > 15) { myString = myString.Substring(0, 15); }

Cheers


#3

Worked perfectly. Thank you.


#4

I know there is a better way to format these numbers but I do not remember how!


#5

I didn’t try with .NetMF, but .ToString(“F2”), for example, will format the double to 12.65


#6

Yes I think this is the right way to do it on netmf


#7

yes the .ToString(“F2”) is F + the number of decimals wanted but it is not truncated. 12.689 --> 12.69 the trouble is and if someone can tell me how that would be great!!! I don’t know how to indicate that the entire number after and before the . is 15 lenght.

any idea??


#8

Something like the c formatting : %f15.2 ?