gpt4 book ai didi

C#:指向 double 的指针

转载 作者:太空狗 更新时间:2023-10-29 22:34:42 25 4
gpt4 key购买 nike

我有一个声明,在声明中,我想设置一个 height 是一个指向 double 的指针,但得到错误消息:

Error 1 Pointers and fixed size buffers may only be used in an unsafe context,

谁能告诉我在 double 中声明指针类型的正确方法?

下面是我的声明,我将高度设置为 double (double* height) 的指针,但收到错误消息。

private static extern bool GetElevation(double dLat, double dLon, double* height);

最佳答案

您的外部声明可能应该是:

private static extern bool GetElevation(double dLat, double dLon, ref double height);

希望这对您有所帮助!

编辑

question (和接受的答案)可能会阐明这个问题。它讨论了 refout(不确定哪个更适合您的情况)和编码。

关于C#:指向 double 的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4083289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com