I have some fields returned by a collection as
2.4200
2.0044
2.0000
I want results like
2.42
2.0044
2
I tried with String.Format
, but it returns 2.0000
and setting it to N0
rounds the other values as well.
I have some fields returned by a collection as
2.4200
2.0044
2.0000
I want results like
2.42
2.0044
2
I tried with String.Format
, but it returns 2.0000
and setting it to N0
rounds the other values as well.
In case you want to keep decimal number, try following example:
You can just set as:
Very simple answer is to use TrimEnd(). Here is the result,
Output is 1 If my value is 1.01 then my output will be 1.01
I use this code to avoid "G29" scientific notation: