本文介绍了无法将int更改为string的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
今天我试图编写一个数独游戏,并希望使用文本框作为数字持有者。这就是为什么我想随机把这个号码放到文本框中但是我没有工作。
Today i was trying to code a sudoku game and wanted to use textboxes as number holders. That''s why i wanted to random and put that number in to the textbox but i didn''t work out.
TextBox[] dene = new TextBox[10];
for (int i = 0; i < 9; i++)
{
Random b = new Random();
int inta = b.Next(1,9);
string a = inta.ToString();
dene[i].Text = a;
}
_0 = dene[0];
_1 = dene[1];
_2 = dene[2];
_3 = dene[3];
_4 = dene[4];
_5 = dene[5];
_6 = dene[6];
_7 = dene[7];
_8 = dene[8];
这是我使用的代码,但它在dene [i] .Text = a时抛出错误;请帮助^^
This is the code i use but it throws an error during dene[i].Text=a; pls help ^^
推荐答案
for (int i = 0; i < 10; i++)
dene[i] = new TextBox();
这篇关于无法将int更改为string的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!