I used:
Result_TextBox.Text = result.ToString(".#######"); //result is double
But if the result is 100.0000000, it becomes 100. What should I use in order to keep the accuracy of 7 decimals place?
I tried:
Result_TextBox.Text = Math.round(result, 7); //but this is effective at all, why?
Please help
Update: can someone explain "#" and "0"?
Use:
Result_TextBox.Text = result.ToString("0.0000000");
The second line doesn't work because you're trying to assign a numeric data type to a string without conversion.
这有效
Result_TextBox.Text = result.ToString("#.0000000");
尝试:
result.ToString("0.0000000")
There is a Standard numeric format strings for that.
You can use The Fixed-Point ("F") Format Specifier followed by a number to define the number of decimal digits.
Console.WriteLine(100.ToString("F7"));
// -> 100.0000000
Console.WriteLine(100.ToString("F3"));
// -> 100.000
Example : https://dotnetfiddle.net/EmPewm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.