相关疑难解决方法(0)

在类型中使用F#索引属性

我正在尝试将以下C#转换为F#:

    public class Matrix
    {
       double[,] matrix;

public int Cols
        {
            get
            {
                return this.matrix.GetUpperBound(1) + 1;
            }
        }

public int Rows
        {
            get
            {
                return this.matrix.GetUpperBound(0) + 1;
            }
        }

       public Matrix(double[,] sourceMatrix)
       {
        this.matrix = new double[sourceMatrix.GetUpperBound(0) + 1, sourceMatrix.GetUpperBound(1) + 1];
        for (int r = 0; r < this.Rows; r++)
        {
            for (int c = 0; c < this.Cols; c++)
            {
                this[r, c] = sourceMatrix[r, c];
            }
        }
       }

       public double this[int row, int col]
       {
         get …
Run Code Online (Sandbox Code Playgroud)

f# types indexed-properties

1
推荐指数
1
解决办法
708
查看次数

标签 统计

f# ×1

indexed-properties ×1

types ×1