开发者

Convert pointer to loop option in C#

开发者 https://www.devze.com 2023-02-08 10:35 出处:网络
How would I convert this into 开发者_JAVA百科a loop and not to use the pointer. byte[] InputBuffer = new byte[8];

How would I convert this into 开发者_JAVA百科a loop and not to use the pointer.

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

I am trying to use the code from this page: query string parameter obfuscation


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

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

replaces all six original lines of code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号