二维数组的基是什么意思?从零开始的数组是什么意思?在MSDN中对此一言不发。
答案 0 :(得分:2)
它是数组的下限:
let matrix : int [,]= Array2D.zeroCreateBased 10 20 5 7
for x in 10..14 do
for y in 20..26 do
printfn "%A" matrix.[x, y]
您可以通过以下方式获得上下限:
let x1 = matrix.GetLowerBound 0
let x2 = matrix.GetUpperBound 0
let y1 = matrix.GetLowerBound 1
let y2 = matrix.GetUpperBound 1
或类似这样:
let x1 = Array2D.base1 matrix
let x2 = Array2D.length1 matrix + x1 - 1
let y1 = Array2D.base2 matrix
let y2 = Array2D.length2 matrix + y1 - 1
printfn "%A" (x1, y1) // (10, 20)
printfn "%A" (x2, y2) // (14, 26)
基于零表示他们的第一个元素索引为0