【发布时间】:2014-02-09 10:40:46
【问题描述】:
我正在尝试构造一个二维矩阵,其中 T 是数字(整数,浮点十进制),但是当我尝试从二维数组 T[,] 创建构造函数时,它不允许我获取长度( 0)和长度(1),只有长度。然后我需要减去、乘以和添加 Matrix 的实例,但是如果没有二维,我将无法通过它们。 编译器错误:需要方法、委托或事件。谢谢。
using System;
public class Matrix<T>
where T : struct,
IComparable<T>,
IConvertible,
IEquatable<T>,
IFormattable
{
readonly T[,] matr;
public int rows;
public int Rows
{
get { return rows; }
}
public int Cols
{
get { return cols; }
}
public int cols;
public Matrix(T[,] table)
{
matr = table;
rows = matr.Length(0);//problem here
cols = matr.Length(1);//problem here
}
【问题讨论】: