更新时间:2023-10-03 18:14:46
另一种变化是:
Another variation is:
textBox1.text = player.ToString();
此版本中的一个细微差别是您可以定义数字显示的格式.例如,您可以将格式定义为:
A slight difference in this version is that you can define the format for the number presentation. For example, you can define the format as:
textBox1.text = player.ToString("#00");
而数字4的结果将是"04".
详细信息: Int32.ToString方法 [
And the result with number 4 would be "04".
More info: Int32.ToString Method [^]
您直接将整数值分配给string
.
除非您在分配之前将其强制类型转换为string
,否则它将无法正常工作.
尝试textBox1.text = Convert.ToString(player);
You are directly assigning an integer value to astring
.
This won''t work until you type cast it into astring
before assignment.
TrytextBox1.text = Convert.ToString(player);