Format decimal for percentage values?

前端 未结 5 695
别跟我提以往
别跟我提以往 2020-11-28 23:17

What I want is something like this:

String.Format(\"Value: {0:%%}.\", 0.8526)

Where %% is that format provider or whatever I am looking for

5条回答
  •  庸人自扰
    2020-11-28 23:38

    Use the P format string. This will vary by culture:

    String.Format("Value: {0:P2}.", 0.8526) // formats as 85.26 % (varies by culture)
    

提交回复
热议问题