将双精度[,]转换为变量*

Convert double[,] to Variant*

本文关键字:变量 转换 双精度      更新时间:2023-10-16

在我的应用程序中,我试图从我的WPF应用程序调用atlcom类的函数。atlcom类函数的参数如下:

[id(5)] HRESULT GetFormationZPoints([in] BSTR sLyrName, [in,out] VARIANT* pLandingPoints);

在WPF方面,我试图传递一个double的二维数组,像这样

List<PointsVector> landingPoints = Planner.LandingPointsList;
double[,] dLPs = new double[landingPoints.Count, 3];
int i = 0;
foreach (PointsVector v in landingPoints)
{
    dLPs[i, 0] = v.X;
    dLPs[i, 1] = v.Y;
    dLPs[i, 2] = v.Z;
    i++;
}
gaInfo.GetFormationZPoints(targetReservoir.TargetLayerName, ref dLPs);

我得到以下错误信息:

参数2:不能从'ref double[]'转换为'ref object

如异常中所述,您可以将dlp变量转换为对象并查看它是否有效。基本上应该是这样的

    gaInfo.GetFormationZPoints(targetReservoir.TargetLayerName, ref (object) dLPs);