public static void OntoBuffer(byte[] buffer, int i, ref int offset) { ByteToInteger b2i = new ByteToInteger() { integer = i }; buffer[offset] = b2i.b0; buffer[offset + 1] = b2i.b1; buffer[offset + 2] = b2i.b2; buffer[offset + 3] = b2i.b3; Interlocked.Add(ref offset, 4); }
public static byte[] GetBytes(int i) { ByteToInteger b2i = new ByteToInteger() { integer = i }; return new byte[4] { b2i.b0, b2i.b1, b2i.b2, b2i.b3 }; }