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

定义

使用尽可能少的字节数将此 BigInteger 的值复制为小端二进制补码字节。Copies the value of this BigInteger as little-endian twos-complement bytes, using the fewest number of bytes possible. 如果值为零,则输入其元素为 0x00 的字节。If the value is zero, outputs one byte whose element is 0x00.

public bool TryWriteBytes (Span<byte> destination, out int bytesWritten, bool isUnsigned = false, bool isBigEndian = false);
member this.TryWriteBytes : Span<byte> * int * bool * bool -> bool
Public Function TryWriteBytes (destination As Span(Of Byte), ByRef bytesWritten As Integer, Optional isUnsigned As Boolean = false, Optional isBigEndian As Boolean = false) As Boolean

参数

destination
Span<Byte>

应写入生成字节的目标跨度。The destination span to which the resulting bytes should be written.

bytesWritten
Int32

写入到 destination 的字节数。The number of bytes written to destination.

isUnsigned
Boolean

如果使用无符号编码,则为 true;否则为 falsetrue to use unsigned encoding; otherwise, false.

isBigEndian
Boolean

如果以大端字节顺序写入字节,则为 true;否则为 falsetrue to write the bytes in a big-endian byte order; otherwise, false.

返回

如果字节满足 true,则为 destination;如果由于空间不足而无法写入所有字节,则为 falsetrue if the bytes fit in destination; false if not all bytes could be written due to lack of space.

异常

isUnsignedtrueSign 为负。isUnsigned is true and Sign is negative.

适用于