由网友(心凉透死心了对吗 \"\")分享简介:我要显示在文本框下面所示的矩阵,但我不知道从哪里开始。我怎样才能得到这样的结果在一个文本框?5 5 5 58 9 3 17 9 2 73 7 8 68 3 1 2解决方案 INT [,]矩阵=新INT [,] {{5,5,5,5},{8,9,3,1},{7,9,2,7},{3,7,8,6},{8,3,1,2}};您...![Excel 怎样在窗口输入关键字符串,定位单元格](https://p.xsw88.cn/allimgs/daicuo/20230907/5532.png)
我要显示在文本框下面所示的矩阵,但我不知道从哪里开始。我怎样才能得到这样的结果在一个文本框?
5 5 5 5
8 9 3 1
7 9 2 7
3 7 8 6
8 3 1 2
解决方案
INT [,]矩阵=新INT [,] {{5,5,5,5},
{8,9,3,1},
{7,9,2,7},
{3,7,8,6},
{8,3,1,2}};
您需要创建一个多行文本框
来显示这些信息。然后使用类似这样写的矩阵到文本框
:
字符串matrixString =;
的for(int i = 0; I< matrix.GetLength(0);我++)
{
为(诠释J = 0; J&其中; matrix.GetLength(1); J ++)
{
matrixString + =矩阵[I,J]的ToString();
matrixString + =;
}
matrixString + = Environment.NewLine;
}
this.textBoxName.Text = matrixString;
![Excel 怎样在窗口输入关键字符串,定位单元格](https://p.xsw88.cn/allimgs/daicuo/20230907/5532.png)
您得到这样的结果:
I want to display a matrix as shown below in a textbox, but I don't know where to start. How can I get this result in a textbox?
5 5 5 5
8 9 3 1
7 9 2 7
3 7 8 6
8 3 1 2
解决方案
int[,] matrix = new int[,] {{5, 5, 5, 5},
{8, 9, 3, 1},
{7, 9, 2, 7},
{3, 7, 8, 6},
{8, 3, 1, 2}};
You will need to create a multiline TextBox
to show this information. Then use something like this to write the matrix to the TextBox
:
string matrixString = "";
for (int i = 0; i < matrix.GetLength(0); i++)
{
for (int j = 0; j < matrix.GetLength(1); j++)
{
matrixString += matrix[i, j].ToString();
matrixString += " ";
}
matrixString += Environment.NewLine;
}
this.textBoxName.Text = matrixString;
You get this result:
相关推荐
最新文章