[英]Can someone explain what is this code does?
Can anyone please explain what does the this code does? 谁能解释一下这段代码的作用吗? Just confused on the this portion of the code ( this.matrix = new int[rows, cols];
). 只是对这部分代码感到困惑( this.matrix = new int[rows, cols];
)。
class Matrix
{
private int[,] matrix;
public Matrix(int rows, int cols)
{
this.matrix = new int[rows, cols];
}
}
That code assigns a class variable called matrix
a new 2d array that has x number of rows and x number of columns.. 该代码为名为matrix
的类变量分配了一个新的2d数组,该数组具有x行数和x列数。
Of course these aren't mapped to rows and columns as you would see in excel but basically just saying the first array has rows
length, and the second column
length such as.. 当然,它们并没有像您在excel中看到的那样映射到行和列,而基本上只是说第一个数组具有rows
,而第二个column
诸如..
row1: col col col 第1行:col col col col
row2: col col col 第2行:col col col
is a int[2,3]
as is 是原样的int[2,3]
col1: row row row col1:行行行
col2: row row row col2:行行行
This is all done in the constructor of an instance of a Matrix
这些都是在Matrix
实例的构造函数中完成的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.