日期:2014-05-17  浏览次数:20899 次

求教String.Format时有多个数值时该怎么写?
C/C++ code

   String str;
   str = String.Format("\nFL:   {0:F0}kg   {0:P}", wei[0], prc[0]);


我现在是这样写的,但是{0:P}显示百分数时总是显示wei[0]的值,该怎么写才是对的呢?

------解决方案--------------------
C# code

 String str;
   str = String.Format("\nFL:   {0:F0}kg   {1:P}", wei[0], prc[0]);

------解决方案--------------------
String str;
str = String.Format("\nFL: {0:F0}kg {0:P}", wei[0], prc[0]);

把 {0:P} 中的0 改为1 试试。


------解决方案--------------------
C# code

str = String.Format("\nFL: {0:F0}kg [color=#FF0000]{1:P}[/color]", wei[0], prc[0]);