/// <summary>Encode the value as an ILInt in the provided buffer, in the specified range.</summary> /// <param name="value">The value.</param> /// <param name="buffer">The buffer.</param> /// <param name="offset">The offset to start storing bytes in the buffer.</param> /// <param name="count">The maximum count of bytes that can be stored, it may not be enough in which case it throws.</param> /// <returns>The provided buffer.</returns> /// <exception cref="TooFewBytesException"></exception> public static byte[] ILIntEncode(this ulong value, byte[] buffer, int offset, int count) { ByteArrayExtensions.CheckBuffer(buffer, offset, count); ILIntEncode(value, b => { if (--count < 0) { throw new TooFewBytesException(); } buffer[offset++] = b; }); return(buffer); }