public static WriteUInt16 ( byte array, int offset, ushort value ) : void | ||
array | byte | |
offset | int | |
value | ushort | |
리턴 | void |
/// <summary> /// Writes the compact encoding of value to a destination byte array, starting at offset. /// </summary> /// <returns>The number of bytes written to destination.</returns> public static int WriteCompact(byte[] destination, int offset, ulong value) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } if (value < 0xfd) { destination[offset] = (byte)value; return(1); } else if (value <= ushort.MaxValue) { destination[offset] = 0xfd; LittleEndian.WriteUInt16(destination, offset + 1, (ushort)value); return(3); } else if (value <= uint.MaxValue) { destination[offset] = 0xfe; LittleEndian.WriteUInt32(destination, offset + 1, (uint)value); return(5); } else { destination[offset] = 0xff; LittleEndian.WriteUInt64(destination, offset + 1, value); return(9); } }
public void WriteUInt16(ushort value) { LittleEndian.WriteUInt16(_array, _cursor, value); _cursor += 2; }