Untitled


SUBMITTED BY: Guest

DATE: Aug. 4, 2017, 12:10 p.m.

FORMAT: Text only

SIZE: 867 Bytes

HITS: 265

  1. public static void Write(int arg, int offset, byte[] buffer)
  2. {
  3. if (buffer == null)
  4. {
  5. return;
  6. }
  7. if (offset > buffer.Length - 1)
  8. {
  9. return;
  10. }
  11. if (buffer.Length >= offset + sizeof(uint))
  12. {
  13. unsafe
  14. {
  15. #if UNSAFE
  16. fixed (byte* Buffer = buffer)
  17. {
  18. *((int*)(Buffer + offset)) = arg;
  19. }
  20. #else
  21. buffer[offset] = (byte)(arg);
  22. buffer[offset + 1] = (byte)(arg >> 8);
  23. buffer[offset + 2] = (byte)(arg >> 16);
  24. buffer[offset + 3] = (byte)(arg >> 24);
  25. #endif
  26. }
  27. }
  28. }

comments powered by Disqus