转换的指针在C#循环选项 [英] Convert pointer to loop option in C#

查看:208
本文介绍了转换的指针在C#循环选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何转换这种成一个圈,而不是使用指针。

How would I convert this into a loop and not to use the pointer.

byte[] InputBuffer = new byte[8];
unsafe {
      fixed (byte* pInputBuffer = InputBuffer) {
         ((long*)pInputBuffer)[0] = value;
      }
}

我想用code从该页面:查询字符串参数迷惑

推荐答案

这里有没有循环。您可以使用 BitConverter.GetBytes 而不是不安全类型夯实投

There's no looping here. You could use BitConverter.GetBytes instead of the unsafe type-punning cast.

byte[] InputBuffer = BitConverter.GetBytes(value);

替换所有六个原线code。

replaces all six original lines of code.

这篇关于转换的指针在C#循环选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆