BigInteger.TryWriteBytes(Span<Byte>, Int32, Boolean, Boolean) Method

Definition

Copies the value of this BigInteger as little-endian twos-complement bytes, using the fewest number of bytes possible. If the value is zero, outputs one byte whose element is 0x00.

C#
public bool TryWriteBytes(Span<byte> destination, out int bytesWritten, bool isUnsigned = false, bool isBigEndian = false);

Parameters

destination
Span<Byte>

The destination span to which the resulting bytes should be written.

bytesWritten
Int32

The number of bytes written to destination.

isUnsigned
Boolean

true to use unsigned encoding; otherwise, false.

isBigEndian
Boolean

true to write the bytes in a big-endian byte order; otherwise, false.

Returns

true if the bytes fit in destination; false if not all bytes could be written due to lack of space.

Exceptions

isUnsigned is true and Sign is negative.

Applies to

Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1