如何将数1000格式化为1,000textbox
到使用的Tostring
的标签,并在C#中message.show
myString =“尝试编号” + AttemptNumber.ToString();
AttemptsLbl.Text = AttemptNumber.ToString();
MessageBox.Show(“找到所有3位数字的匹配-花了” + AttemptNumber +“ trys!”);
使用此格式#,##0
,可以在ToString
或中使用String.Format
。在字符串中间插入数字时,我发现String.Format
更方便。下面的两个示例。
myString = String.Format("Attempt #{0:#,##0}", AttemptNumber);
AttemptsLbl.Text = AttemptNumber.ToString("#,##0");
MessageBox.Show(String.Format("Match Found for All 3 Digits - it took {0:#,##0} tries!", AttemptNumber));
此问答中的格式字符串:https : //stackoverflow.com/a/295821/832052
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句