BitConverter.TryWriteBytes Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
TryWriteBytes(Span<Byte>, Int64) |
Converts a 64-bit signed integer into a span of bytes. |
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>, Half) |
Converts a half-precision floating-point value into a span of bytes. |
TryWriteBytes(Span<Byte>, Int128) |
Converts a 128-bit signed integer 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>, Single) |
Converts a single-precision floating-point value into a span of bytes. |
TryWriteBytes(Span<Byte>, UInt128) |
Converts a 128-bit unsigned integer 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>, Int64)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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>, Boolean)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
- value
- Boolean
The Boolean to convert.
Returns
true
if the conversion was successful; false
otherwise.
Applies to
TryWriteBytes(Span<Byte>, Char)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
- value
- Char
The character to convert.
Returns
true
if the conversion was successful; false
otherwise.
Applies to
TryWriteBytes(Span<Byte>, Double)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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>, Half)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
Converts a half-precision floating-point value into a span of bytes.
public:
static bool TryWriteBytes(Span<System::Byte> destination, Half value);
public static bool TryWriteBytes (Span<byte> destination, Half value);
static member TryWriteBytes : Span<byte> * Half -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Half) As Boolean
Parameters
When this method returns, the bytes representing the converted half-precision floating-point value.
- value
- Half
The half-precision floating-point value to convert.
Returns
true
if the conversion was successful; false
otherwise.
Applies to
TryWriteBytes(Span<Byte>, Int128)
- Source:
- BitConverter.cs
Converts a 128-bit signed integer into a span of bytes.
public:
static bool TryWriteBytes(Span<System::Byte> destination, Int128 value);
public static bool TryWriteBytes (Span<byte> destination, Int128 value);
static member TryWriteBytes : Span<byte> * Int128 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As Int128) As Boolean
Parameters
When this method returns, the bytes representing the converted 128-bit signed integer.
- value
- Int128
The 128-bit signed integer to convert.
Returns
true
if the conversion was successful; false
otherwise.
Applies to
TryWriteBytes(Span<Byte>, Int16)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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>, Single)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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>, UInt128)
- Source:
- BitConverter.cs
Important
This API is not CLS-compliant.
Converts a 128-bit unsigned integer into a span of bytes.
public:
static bool TryWriteBytes(Span<System::Byte> destination, UInt128 value);
[System.CLSCompliant(false)]
public static bool TryWriteBytes (Span<byte> destination, UInt128 value);
[<System.CLSCompliant(false)>]
static member TryWriteBytes : Span<byte> * UInt128 -> bool
Public Shared Function TryWriteBytes (destination As Span(Of Byte), value As UInt128) As Boolean
Parameters
When this method returns, the bytes representing the converted 128-bit unsigned integer.
- value
- UInt128
The 128-bit unsigned integer to convert.
Returns
true
if the conversion was successful; false
otherwise.
- Attributes
Applies to
TryWriteBytes(Span<Byte>, UInt16)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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)
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
- Source:
- BitConverter.cs
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
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
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for