BitConverter.TryWriteBytes Method

Definition

Overloads

Name Description
TryWriteBytes(Span<Byte>, Boolean)

Converts a Boolean into a span of bytes.

TryWriteBytes(Span<Byte>, Char)

Converts a character into a span of bytes.

TryWriteBytes(Span<Byte>, Double)

Converts a double-precision floating-point value into a span of bytes.

TryWriteBytes(Span<Byte>, Int16)

Converts a 16-bit signed integer into a span of bytes.

TryWriteBytes(Span<Byte>, Int32)

Converts a 32-bit signed integer into a span of bytes.

TryWriteBytes(Span<Byte>, Int64)

Converts a 64-bit signed integer into a span of bytes.

TryWriteBytes(Span<Byte>, Single)

Converts a single-precision floating-point value into a span of bytes.

TryWriteBytes(Span<Byte>, UInt16)

Converts an unsigned 16-bit integer into a span of bytes.

TryWriteBytes(Span<Byte>, UInt32)

Converts a 32-bit unsigned integer into a span of bytes.

TryWriteBytes(Span<Byte>, UInt64)

Converts an unsigned 64-bit integer into a span of bytes.

TryWriteBytes(Span<Byte>, Boolean)

Converts a Boolean into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, bool value);
public static bool TryWriteBytes(Span<byte> destination, bool value);
static member TryWriteBytes : Span<byte> * bool -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Boolean) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted Boolean.

value
Boolean

The Boolean to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, Char)

Converts a character into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, char value);
public static bool TryWriteBytes(Span<byte> destination, char value);
static member TryWriteBytes : Span<byte> * char -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Char) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted character.

value
Char

The character to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, Double)

Converts a double-precision floating-point value into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, double value);
public static bool TryWriteBytes(Span<byte> destination, double value);
static member TryWriteBytes : Span<byte> * double -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Double) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted double-precision floating-point value.

value
Double

The double-precision floating-point value to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, Int16)

Converts a 16-bit signed integer into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, short value);
public static bool TryWriteBytes(Span<byte> destination, short value);
static member TryWriteBytes : Span<byte> * int16 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Short) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted 16-bit signed integer.

value
Int16

The 16-bit signed integer to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, Int32)

Converts a 32-bit signed integer into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, int value);
public static bool TryWriteBytes(Span<byte> destination, int value);
static member TryWriteBytes : Span<byte> * int -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Integer) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted 32-bit signed integer.

value
Int32

The 32-bit signed integer to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, Int64)

Converts a 64-bit signed integer into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, long value);
public static bool TryWriteBytes(Span<byte> destination, long value);
static member TryWriteBytes : Span<byte> * int64 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Long) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted 64-bit signed integer.

value
Int64

The 64-bit signed integer to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, Single)

Converts a single-precision floating-point value into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, float value);
public static bool TryWriteBytes(Span<byte> destination, float value);
static member TryWriteBytes : Span<byte> * single -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Single) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted single-precision floating-point value.

value
Single

The single-precision floating-point value to convert.

Returns

true if the conversion was successful; false otherwise.

Applies to

TryWriteBytes(Span<Byte>, UInt16)

Important

This API is not CLS-compliant.

Converts an unsigned 16-bit integer into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, System::UInt16 value);
[System.CLSCompliant(false)]
public static bool TryWriteBytes(Span<byte> destination, ushort value);
[<System.CLSCompliant(false)>]
static member TryWriteBytes : Span<byte> * uint16 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As UShort) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted unsigned 16-bit integer.

value
UInt16

The unsigned 16-bit integer to convert.

Returns

true if the conversion was successful; false otherwise.

Attributes

Applies to

TryWriteBytes(Span<Byte>, UInt32)

Important

This API is not CLS-compliant.

Converts a 32-bit unsigned integer into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, System::UInt32 value);
[System.CLSCompliant(false)]
public static bool TryWriteBytes(Span<byte> destination, uint value);
[<System.CLSCompliant(false)>]
static member TryWriteBytes : Span<byte> * uint32 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As UInteger) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted unsigned 32-bit integer.

value
UInt32

The unsigned 32-bit integer to convert.

Returns

true if the conversion was successful; false otherwise.

Attributes

Applies to

TryWriteBytes(Span<Byte>, UInt64)

Important

This API is not CLS-compliant.

Converts an unsigned 64-bit integer into a span of bytes.

public:
 static bool TryWriteBytes(Span<System::Byte> destination, System::UInt64 value);
[System.CLSCompliant(false)]
public static bool TryWriteBytes(Span<byte> destination, ulong value);
[<System.CLSCompliant(false)>]
static member TryWriteBytes : Span<byte> * uint64 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As ULong) As Boolean

Parameters

destination
Span<Byte>

When this method returns, the bytes representing the converted unsigned 64-bit integer.

value
UInt64

The unsigned 64-bit integer to convert.

Returns

true if the conversion was successful; false otherwise.

Attributes

Applies to