我有以下C#代码,该代码具有3-dim double,然后将其复制到11x3 double:

var i = 8;
var temprate = new double[]{1,2,3};
var RATES = new double[11,3]

RATES[i, 0] = temprate[0];
RATES[i, 1] = temprate[1];
RATES[i, 2] = temprate[2];


如何将temprate直接复制到RATES中(最好没有循环)?

即:"RATES[i,*]=temprate"

最佳答案

Buffer.BlockCopy(temprate, 0, RATES, i * 3 * sizeof(double), 3 * sizeof(double));

关于c# - 将3维数组复制到11x3维数组C#,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32678478/

10-10 17:18