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 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退