This works just fine, don't need the substring.
var results = string.Format("{0:00000000.0}", 191.5));
質問
In C#, using the double number 191.5 (example), I want to create a string that:
My code :
strOut += SubString(10, string.Format("{0:0000000000}", 191.5));
The problem with my code is that :
My code output :
0000000192
The output I need :
00000191.5
解決
This works just fine, don't need the substring.
var results = string.Format("{0:00000000.0}", 191.5));
他のヒント
I believe
strOut += SubString(10, string.Format("{0:00000000.0}", 191.5));
does what you want. However, you don't really need the substring in this case unless you are sometimes expecting some much larger numbers and want to truncate them.
try this one
double num=192.5;
strOut += SubString(10, string.Format("{0:#}", num));