sony_song 2019-10-25 17:54 采纳率: 0%
浏览 1868
已结题

IntPtr和Byte转化的问题

调用C+的dll出现一个错误,请大神帮忙看看错在哪里
try
{
byte[] array2;
byte* ptr;
if ((array2 = array) != null && array2.Length != 0)
{
fixed (byte* ptr1 = &array2[0])
{
}
}
else
{
ptr = null;
}
for (long num2 = 0L; num2 < (long)num; num2 += 3L)
{
//这里报错 Operator '/' cannot be applied to operands of type 'System.IntPtr' and 'System.IntPtr'
byte b = ptr[(IntPtr)num2 / 1];

                    //这里报错 Operator '/' cannot be applied to operands of type 'System.IntPtr' and 'int'
                    ptr[(IntPtr)num2 / 1] = *(ptr + (IntPtr)(num2 + 2L) / 1);
                    //这里也报错  Operator '/' cannot be applied to operands of type 'System.IntPtr' and 'int'
                    ptr[(IntPtr)(num2 + 2L) / 1] = b;
                }
            }
            finally
            {
                byte* ptr = null;
            }

请大神帮忙解决一下啊

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-10-25 22:51
    关注

    你这是反编译的代码?
    ptr[(IntPtr)num2 / 1]
    这种写法很奇怪,不像合理的人写的代码
    应该是
    ptr[num2]
    或者 *(ptr + num2)

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料