我定义了一个类是Complex; 又定义了一个类是Matrix; public class Complex
{
double re;
double im;
public double Re
{
get { return re; }
set { re = value; }
} public double Im
{
get { return im; }
set { im = value; }
}
} public class Matrix
{ private ArrayList Values; public int RowCount
{
get { return rowCount; }
} public int ColumnCount
{
get { return columnCount; }
} private int rowCount; public Matrix()
{
Values = new ArrayList();
rowCount = 0;
columnCount = 0;
}
public Matrix(Complex[,] values)
{
if (values == null)
{
Values = new ArrayList();
columnCount = 0;
rowCount = 0;
} rowCount = (int)values.GetLongLength(0);
columnCount = (int)values.GetLongLength(1); Values = new ArrayList(rowCount); for (int i = 0; i < rowCount; i++)
{
Values.Add(new ArrayList(columnCount)); for (int j = 0; j < columnCount; j++)
{
((ArrayList)Values[i]).Add(values[i, j]);
}
}
}
}现在想在主程序中实现这样的操作,即:Matrix a = new Matrix (Complex[,] b);
来建立将复数数组b中的数值赋到a 矩阵中,请问如何才能实现?现在这种状态下, a只带有行宽,列宽属性,但Values无法获得。请问这种情况如何解决?
如果按我这种方式进行数据读取,是不是需要再定义一个Complex[,]类型,然后才能进入到Matix操作部分?