Search code examples
c#winformsfloating-pointdigit

Trimming a float


Possible Duplicate:
Leave only two decimal places after the dot
Formatting a float to 2 decimal places

If I have a float that consists of something like 153.2154879, is there any way to convert it to string but only show 4 decimal places? I know I can format it using "000.000", but the front number doesnt always have to be 3 digits. So is there a way to show all the front numbers (153), but only the first 4 characters after the point in a string?


Solution

  • I usually use a format string like "#0.0000".