如何在随机生成的数字C#winforms中添加逗号

时间:2015-09-03 04:15:49

标签: c# winforms

目前我有这段代码:

private void button1_Click(object sender, EventArgs e)
{
    label1.Text = (new Random().NextDouble() * (new Random()).Next(10000)).ToString("0.00");
    //if (this.label1.Text.Length >= 7)
    //{
    //    this.label1.Text = string.Format("{0:0,0}", label1.Text);
    //}
}

1-10000生成随机数。我想插入这样的逗号:9,677.89

1 个答案:

答案 0 :(得分:2)

String.Format("{0:N2}", new Random().NextDouble()*10000)