Compartilhar via


BitConverter Classe

Definição

Converte tipos de dados base em uma matriz de bytes e uma matriz de bytes em tipos de dados base.

public ref class BitConverter abstract sealed
public ref class BitConverter sealed
public static class BitConverter
public sealed class BitConverter
type BitConverter = class
Public Class BitConverter
Public NotInheritable Class BitConverter
Herança
BitConverter

Exemplos

O exemplo de código a seguir ilustra o uso de vários métodos de classe BitConverter.

// Example of BitConverter class methods.
using namespace System;
int main()
{
   String^ formatter = "{0,25}{1,30}";
   double aDoubl = 0.1111111111111111111;
   float aSingl = 0.1111111111111111111F;
   __int64 aLong = 1111111111111111111;
   int anInt = 1111111111;
   short aShort = 11111;
   __wchar_t aChar = L'*';
   bool aBool = true;
   Console::WriteLine( "This example of methods of the BitConverter class"
   "\ngenerates the following output.\n" );
   Console::WriteLine( formatter, "argument", "byte array" );
   Console::WriteLine( formatter, "--------", "----------" );
   
   // Convert values to Byte arrays and display them.
   Console::WriteLine( formatter, aDoubl, BitConverter::ToString( BitConverter::GetBytes( aDoubl ) ) );
   Console::WriteLine( formatter, aSingl, BitConverter::ToString( BitConverter::GetBytes( aSingl ) ) );
   Console::WriteLine( formatter, aLong, BitConverter::ToString( BitConverter::GetBytes( aLong ) ) );
   Console::WriteLine( formatter, anInt, BitConverter::ToString( BitConverter::GetBytes( anInt ) ) );
   Console::WriteLine( formatter, aShort, BitConverter::ToString( BitConverter::GetBytes( aShort ) ) );
   Console::WriteLine( formatter, aChar, BitConverter::ToString( BitConverter::GetBytes( aChar ) ) );
   Console::WriteLine( formatter, aBool, BitConverter::ToString( BitConverter::GetBytes( aBool ) ) );
}

/*
This example of methods of the BitConverter class
generates the following output.

                 argument                    byte array
                 --------                    ----------
        0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
                0.1111111                   39-8E-E3-3D
      1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
               1111111111                   C7-35-3A-42
                    11111                         67-2B
                        *                         2A-00
                     True                            01
*/
// Example of BitConverter class methods.
using System;

class BitConverterDemo
{
    public static void Main( )
    {
        const string formatter = "{0,25}{1,30}";

        double  aDoubl  = 0.1111111111111111111;
        float   aSingl  = 0.1111111111111111111F;
        long    aLong   = 1111111111111111111;
        int     anInt   = 1111111111;
        short   aShort  = 11111;
        char    aChar   = '*';
        bool    aBool   = true;

        Console.WriteLine(
            "This example of methods of the BitConverter class" +
            "\ngenerates the following output.\n" );
        Console.WriteLine( formatter, "argument", "byte array" );
        Console.WriteLine( formatter, "--------", "----------" );

        // Convert values to Byte arrays and display them.
        Console.WriteLine( formatter, aDoubl,
            BitConverter.ToString( BitConverter.GetBytes( aDoubl ) ) );
        Console.WriteLine( formatter, aSingl,
            BitConverter.ToString( BitConverter.GetBytes( aSingl ) ) );
        Console.WriteLine( formatter, aLong,
            BitConverter.ToString( BitConverter.GetBytes( aLong ) ) );
        Console.WriteLine( formatter, anInt,
            BitConverter.ToString( BitConverter.GetBytes( anInt ) ) );
        Console.WriteLine( formatter, aShort,
            BitConverter.ToString( BitConverter.GetBytes( aShort ) ) );
        Console.WriteLine( formatter, aChar,
            BitConverter.ToString( BitConverter.GetBytes( aChar ) ) );
        Console.WriteLine( formatter, aBool,
            BitConverter.ToString( BitConverter.GetBytes( aBool ) ) );
    }
}

/*
This example of methods of the BitConverter class
generates the following output.

                 argument                    byte array
                 --------                    ----------
        0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
                0.1111111                   39-8E-E3-3D
      1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
               1111111111                   C7-35-3A-42
                    11111                         67-2B
                        *                         2A-00
                     True                            01
*/
open System

let print: obj -> obj -> unit = printfn "%25O%30O"

let aDoubl = 0.1111111111111111111
let aSingl = 0.1111111111111111111f
let aLong = 1111111111111111111L
let anInt = 1111111111
let aShort = 11111s
let aChar = '*'
let aBool = true

printfn "This example of methods of the BitConverter class\ngenerates the following output.\n"
print "argument" "byte array"
print "--------" "----------"

// Convert values to Byte arrays and display them.
print aDoubl (BitConverter.ToString(BitConverter.GetBytes aDoubl))

print aSingl (BitConverter.ToString(BitConverter.GetBytes aSingl))

print aLong (BitConverter.ToString(BitConverter.GetBytes aLong))

print anInt (BitConverter.ToString(BitConverter.GetBytes anInt))

print aShort (BitConverter.ToString(BitConverter.GetBytes aShort))

print aChar (BitConverter.ToString(BitConverter.GetBytes aChar))

print aBool (BitConverter.ToString(BitConverter.GetBytes aBool))


// This example of methods of the BitConverter class
// generates the following output.
//
//                  argument                    byte array
//                  --------                    ----------
//         0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
//                 0.1111111                   39-8E-E3-3D
//       1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
//                1111111111                   C7-35-3A-42
//                     11111                         67-2B
//                         *                         2A-00
//                      True                            01
' Example of BitConverter class methods.
Module BitConverterDemo

    Sub Main( )

        Const formatter As String = "{0,25}{1,30}"
 
        Dim aDoubl      As Double   = 0.1111111111111111111
        Dim aSingl      As Single   = 0.1111111111111111111
        Dim aLong       As Long     = 1111111111111111111
        Dim anInt       As Integer  = 1111111111
        Dim aShort      As Short    = 11111
        Dim aChar       As Char     = "*"c
        Dim aBool       As Boolean  = True

        Console.WriteLine( _
            "This example of methods of the BitConverter class" & _
            vbCrLf & "generates the following output." & vbCrLf )
        Console.WriteLine( formatter, "argument", "Byte array" )
        Console.WriteLine( formatter, "--------", "----------" )

        ' Convert values to Byte arrays and display them.
        Console.WriteLine( formatter, aDoubl, _
            BitConverter.ToString( BitConverter.GetBytes( aDoubl ) ) )
        Console.WriteLine( formatter, aSingl, _
            BitConverter.ToString( BitConverter.GetBytes( aSingl ) ) )
        Console.WriteLine( formatter, aLong, _
            BitConverter.ToString( BitConverter.GetBytes( aLong ) ) )
        Console.WriteLine( formatter, anInt, _
            BitConverter.ToString( BitConverter.GetBytes( anInt ) ) )
        Console.WriteLine( formatter, aShort, _
            BitConverter.ToString( BitConverter.GetBytes( aShort ) ) )
        Console.WriteLine( formatter, aChar, _
            BitConverter.ToString( BitConverter.GetBytes( aChar ) ) )
        Console.WriteLine( formatter, aBool, _
            BitConverter.ToString( BitConverter.GetBytes( aBool ) ) )
    End Sub
End Module

' This example of methods of the BitConverter class
' generates the following output.
' 
'                  argument                    Byte array
'                  --------                    ----------
'         0.111111111111111       1C-C7-71-1C-C7-71-BC-3F
'                 0.1111111                   39-8E-E3-3D
'       1111111111111111111       C7-71-C4-2B-AB-75-6B-0F
'                1111111111                   C7-35-3A-42
'                     11111                         67-2B
'                         *                         2A-00
'                      True                            01

Comentários

A classe BitConverter ajuda a manipular tipos de valor em sua forma fundamental, como uma série de bytes. Um byte é definido como um inteiro sem sinal de 8 bits. A classe BitConverter inclui métodos estáticos para converter cada um dos tipos primitivos de e para uma matriz de bytes, como ilustra a tabela a seguir.

Tipo Para conversão de bytes Da conversão de bytes
Boolean GetBytes(Boolean) ToBoolean
Char GetBytes(Char) ToChar
Double GetBytes(Double)
-ou-
DoubleToInt64Bits(Double)
-ou-
DoubleToUInt64Bits(Double)
ToDouble
-ou-
Int64BitsToDouble
-ou-
UInt64BitsToDouble
Half GetBytes(Half)
-ou-
HalfToInt16Bits(Half)
-ou-
HalfToUInt16Bits(Half)
ToHalf
-ou-
Int16BitsToHalf
-ou-
UInt16BitsToHalf
Int16 GetBytes(Int16) ToInt16
Int32 GetBytes(Int32) ToInt32
Int64 GetBytes(Int64) ToInt64
Single GetBytes(Single)
-ou-
SingleToInt32Bits(Single)
-ou-
SingleToUInt32Bits(Single)
ToSingle
-ou-
Int32BitsToSingle
-ou-
UInt32BitsToSingle
UInt16 GetBytes(UInt16) ToUInt16
UInt32 GetBytes(UInt32) ToUInt32
UInt64 GetBytes(UInt64) ToUInt64

Se você usar métodos para dados de ida e volta, verifique se a sobrecarga de e o método tipo especificam o mesmo tipo. Como ilustra o exemplo a seguir, restaurar uma matriz que representa um inteiro com sinal chamando o método ToUInt32 pode resultar em um valor diferente do original. Para obter mais informações, consulte Trabalhando com valores não decimais e bit a bit assinados.

using System;

public class Example
{
   public static void Main()
   {
      int value = -16;
      Byte[] bytes = BitConverter.GetBytes(value);

      // Convert bytes back to int.
      int intValue = BitConverter.ToInt32(bytes, 0);
      Console.WriteLine("{0} = {1}: {2}",
                        value, intValue,
                        value.Equals(intValue) ? "Round-trips" : "Does not round-trip");
      // Convert bytes to UInt32.
      uint uintValue = BitConverter.ToUInt32(bytes, 0);
      Console.WriteLine("{0} = {1}: {2}", value, uintValue,
                        value.Equals(uintValue) ? "Round-trips" : "Does not round-trip");
   }
}
// The example displays the following output:
//       -16 = -16: Round-trips
//       -16 = 4294967280: Does not round-trip
open System

let value = -16
let bytes = BitConverter.GetBytes value

// Convert bytes back to int.
let intValue = BitConverter.ToInt32(bytes, 0)
printfn $"""{value} = {intValue}: {if value.Equals intValue then "Round-trips" else "Does not round-trip"}"""

// Convert bytes to UInt32.
let uintValue = BitConverter.ToUInt32(bytes, 0)
printfn $"""{value} = {uintValue}: {if value.Equals uintValue then "Round-trips" else "Does not round-trip"}"""


// The example displays the following output:
//       -16 = -16: Round-trips
//       -16 = 4294967280: Does not round-trip
Module Example
   Public Sub Main()
      Dim value As Integer = -16
      Dim bytes() As Byte = BitConverter.GetBytes(value) 
      
      ' Convert bytes back to Int32.
      Dim intValue As Integer = BitConverter.ToInt32(bytes, 0)
      Console.WriteLine("{0} = {1}: {2}", 
                        value, intValue, 
                        If(value.Equals(intValue), "Round-trips", "Does not round-trip"))
      ' Convert bytes to UInt32.
      Dim uintValue As UInteger = BitConverter.ToUInt32(bytes, 0)
      Console.WriteLine("{0} = {1}: {2}", value, uintValue, 
                        If(value.Equals(uintValue), "Round-trips", "Does not round-trip"))
   End Sub
End Module
' The example displays the following output:
'       -16 = -16: Round-trips
'       -16 = 4294967280: Does not round-trip

A ordem de bytes na matriz retornada pelas sobrecargas do método GetBytes (bem como a ordem dos bits no inteiro retornado pelo método DoubleToInt64Bits) depende se a arquitetura do computador é little-endian ou big-endian. Da mesma forma, a ordem de bytes na matriz e retornada pelos métodos ToIntegerValue e o método ToChar depende se a arquitetura do computador é little-endian ou big-endian. A endianidade de uma arquitetura é indicada pela propriedade IsLittleEndian, que retorna true em sistemas little-endian e false em sistemas big-endian. Em sistemas little-endian, bytes de ordem inferior precedem bytes de ordem superior. No sistema big-endian, bytes de ordem superior precedem bytes de ordem inferior. A tabela a seguir ilustra a diferença nas matrizes de bytes resultantes da passagem do inteiro 1.234.567.890 (0x499602D2) para o método GetBytes(Int32). Os bytes são listados em ordem do byte no índice 0 para o byte no índice 3.

Little-endian D2-02-96-49
Big-endian 49-96-02-D2

Como o valor retornado de alguns métodos depende da arquitetura do sistema, tenha cuidado ao transmitir dados de bytes além dos limites da máquina:

  • Se todos os sistemas que enviam e recebem dados tiverem a mesma endianidade, nada precisa ser feito aos dados.

  • Se os sistemas que enviam e recebem dados podem ter uma endianidade diferente, sempre transmita dados em uma determinada ordem. Isso significa que a ordem dos bytes na matriz pode ter que ser revertida antes de enviá-los ou depois de recebê-los. Uma convenção comum é transmitir dados em ordem de bytes de rede (ordem big-endian). O exemplo a seguir fornece uma implementação para enviar um valor inteiro na ordem de bytes de rede.

    using System;
    
    public class Example
    {
       public static void Main()
       {
          int value = 12345678;
          byte[] bytes = BitConverter.GetBytes(value);
          Console.WriteLine(BitConverter.ToString(bytes));
    
          if (BitConverter.IsLittleEndian)
             Array.Reverse(bytes);
    
          Console.WriteLine(BitConverter.ToString(bytes));
          // Call method to send byte stream across machine boundaries.
    
          // Receive byte stream from beyond machine boundaries.
          Console.WriteLine(BitConverter.ToString(bytes));
          if (BitConverter.IsLittleEndian)
             Array.Reverse(bytes);
    
          Console.WriteLine(BitConverter.ToString(bytes));
          int result = BitConverter.ToInt32(bytes, 0);
          Console.WriteLine("Original value: {0}", value);
          Console.WriteLine("Returned value: {0}", result);
       }
    }
    // The example displays the following output on a little-endian system:
    //       4E-61-BC-00
    //       00-BC-61-4E
    //       00-BC-61-4E
    //       4E-61-BC-00
    //       Original value: 12345678
    //       Returned value: 12345678
    
    open System
    
    let value = 12345678
    let bytes = BitConverter.GetBytes value
    printfn $"{BitConverter.ToString bytes}"
    
    if BitConverter.IsLittleEndian then
        Array.Reverse bytes
    
    printfn $"{BitConverter.ToString bytes}"
    // Call method to send byte stream across machine boundaries.
    
    // Receive byte stream from beyond machine boundaries.
    printfn $"{BitConverter.ToString bytes}"
    if BitConverter.IsLittleEndian then
        Array.Reverse bytes
    
    printfn $"{BitConverter.ToString bytes}"
    let result = BitConverter.ToInt32(bytes, 0)
    
    printfn $"Original value: {value}"
    printfn $"Returned value: {result}"
    
    // The example displays the following output on a little-endian system:
    //       4E-61-BC-00
    //       00-BC-61-4E
    //       00-BC-61-4E
    //       4E-61-BC-00
    //       Original value: 12345678
    //       Returned value: 12345678
    
    Module Example
       Public Sub Main()
          Dim value As Integer = 12345678
          Dim bytes() As Byte = BitConverter.GetBytes(value)
          Console.WriteLine(BitConverter.ToString(bytes))
          
          If BitConverter.IsLittleEndian Then
             Array.Reverse(bytes) 
          End If
          Console.WriteLine(BitConverter.ToString(bytes))
          ' Call method to send byte stream across machine boundaries.
          
          ' Receive byte stream from beyond machine boundaries.
          Console.WriteLine(BitConverter.ToString(bytes))
          If BitConverter.IsLittleEndian Then     
             Array.Reverse(bytes)
          End If   
          Console.WriteLine(BitConverter.ToString(bytes))
          Dim result As Integer = BitConverter.ToInt32(bytes, 0)
          Console.WriteLine("Original value: {0}", value)
          Console.WriteLine("Returned value: {0}", result)
       End Sub
    End Module
    ' The example displays the following output on a little-endian system:
    '       4E-61-BC-00
    '       00-BC-61-4E
    '       00-BC-61-4E
    '       4E-61-BC-00
    '       Original value: 12345678
    '       Returned value: 12345678
    
  • Se os sistemas que enviam e recebem dados podem ter uma endianidade diferente e os dados a serem transmitidos consistem em inteiros assinados, chame o método IPAddress.HostToNetworkOrder para converter os dados em ordem de bytes de rede e o método IPAddress.NetworkToHostOrder para convertê-los na ordem exigida pelo destinatário.

Campos

IsLittleEndian

Indica a ordem de bytes ("endianness") na qual os dados são armazenados nesta arquitetura de computador.

Métodos

DoubleToInt64Bits(Double)

Converte o número de ponto flutuante de precisão dupla especificado em um inteiro com sinal de 64 bits.

DoubleToUInt64Bits(Double)

Converte o número de ponto flutuante de precisão dupla especificado em um inteiro sem sinal de 64 bits.

GetBytes(Boolean)

Retorna o valor booliano especificado como uma matriz de bytes.

GetBytes(Char)

Retorna o valor de caractere Unicode especificado como uma matriz de bytes.

GetBytes(Double)

Retorna o valor de ponto flutuante de precisão dupla especificado como uma matriz de bytes.

GetBytes(Half)

Retorna o valor de ponto flutuante de meia precisão especificado como uma matriz de bytes.

GetBytes(Int128)

Retorna o valor inteiro com sinal de 128 bits especificado como uma matriz de bytes.

GetBytes(Int16)

Retorna o valor inteiro com sinal de 16 bits especificado como uma matriz de bytes.

GetBytes(Int32)

Retorna o valor inteiro com sinal de 32 bits especificado como uma matriz de bytes.

GetBytes(Int64)

Retorna o valor inteiro com sinal de 64 bits especificado como uma matriz de bytes.

GetBytes(Single)

Retorna o valor de ponto flutuante de precisão única especificado como uma matriz de bytes.

GetBytes(UInt128)

Retorna o valor inteiro sem sinal de 128 bits especificado como uma matriz de bytes.

GetBytes(UInt16)

Retorna o valor inteiro sem sinal de 16 bits especificado como uma matriz de bytes.

GetBytes(UInt32)

Retorna o valor inteiro sem sinal de 32 bits especificado como uma matriz de bytes.

GetBytes(UInt64)

Retorna o valor inteiro sem sinal de 64 bits especificado como uma matriz de bytes.

HalfToInt16Bits(Half)

Converte um valor de ponto flutuante de meia precisão em um inteiro de 16 bits.

HalfToUInt16Bits(Half)

Converte o número de ponto flutuante de meia precisão especificado em um inteiro sem sinal de 16 bits.

Int16BitsToHalf(Int16)

Reinterpreta o valor inteiro com sinal de 16 bits especificado como um valor de ponto flutuante de meia precisão.

Int32BitsToSingle(Int32)

Reinterpreta o inteiro de 32 bits especificado como um valor de ponto flutuante de precisão única.

Int64BitsToDouble(Int64)

Reinterpreta o inteiro com sinal de 64 bits especificado para um número de ponto flutuante de precisão dupla.

SingleToInt32Bits(Single)

Converte um valor de ponto flutuante de precisão única em um inteiro.

SingleToUInt32Bits(Single)

Converte o número de ponto flutuante de precisão única especificado em um inteiro sem sinal de 32 bits.

ToBoolean(Byte[], Int32)

Retorna um valor booliano convertido do byte em uma posição especificada em uma matriz de bytes.

ToBoolean(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um valor booliano.

ToChar(Byte[], Int32)

Retorna um caractere Unicode convertido de dois bytes em uma posição especificada em uma matriz de bytes.

ToChar(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um caractere.

ToDouble(Byte[], Int32)

Retorna um número de ponto flutuante de precisão dupla convertido de oito bytes em uma posição especificada em uma matriz de bytes.

ToDouble(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um valor de ponto flutuante de precisão dupla.

ToHalf(Byte[], Int32)

Retorna um número de ponto flutuante de meia precisão convertido de dois bytes em uma posição especificada em uma matriz de bytes.

ToHalf(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um valor de ponto flutuante de meia precisão.

ToInt128(Byte[], Int32)

Retorna um inteiro com sinal de 128 bits convertido de dezesseis bytes em uma posição especificada em uma matriz de bytes.

ToInt128(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um inteiro com sinal de 128 bits.

ToInt16(Byte[], Int32)

Retorna um inteiro com sinal de 16 bits convertido de dois bytes em uma posição especificada em uma matriz de bytes.

ToInt16(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um inteiro com sinal de 16 bits.

ToInt32(Byte[], Int32)

Retorna um inteiro com sinal de 32 bits convertido de quatro bytes em uma posição especificada em uma matriz de bytes.

ToInt32(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um inteiro com sinal de 32 bits.

ToInt64(Byte[], Int32)

Retorna um inteiro com sinal de 64 bits convertido de oito bytes em uma posição especificada em uma matriz de bytes.

ToInt64(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um inteiro com sinal de 64 bits.

ToSingle(Byte[], Int32)

Retorna um número de ponto flutuante de precisão única convertido de quatro bytes em uma posição especificada em uma matriz de bytes.

ToSingle(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um valor de ponto flutuante de precisão única.

ToString(Byte[])

Converte o valor numérico de cada elemento de uma matriz de bytes especificada em sua representação de cadeia de caracteres hexadecimal equivalente.

ToString(Byte[], Int32)

Converte o valor numérico de cada elemento de uma subarray especificada de bytes em sua representação de cadeia de caracteres hexadecimal equivalente.

ToString(Byte[], Int32, Int32)

Converte o valor numérico de cada elemento de uma subarray especificada de bytes em sua representação de cadeia de caracteres hexadecimal equivalente.

ToUInt128(Byte[], Int32)

Retorna um inteiro sem sinal de 128 bits convertido de quatro bytes em uma posição especificada em uma matriz de bytes.

ToUInt128(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um inteiro sem sinal de 128 bits.

ToUInt16(Byte[], Int32)

Retorna um inteiro sem sinal de 16 bits convertido de dois bytes em uma posição especificada em uma matriz de bytes.

ToUInt16(ReadOnlySpan<Byte>)

Converte um byte-span somente leitura em um inteiro sem sinal de 16 bits.

ToUInt32(Byte[], Int32)

Retorna um inteiro sem sinal de 32 bits convertido de quatro bytes em uma posição especificada em uma matriz de bytes.

ToUInt32(ReadOnlySpan<Byte>)

Converte um intervalo de bytes somente leitura em um inteiro sem sinal de 32 bits.

ToUInt64(Byte[], Int32)

Retorna um inteiro sem sinal de 64 bits convertido de oito bytes em uma posição especificada em uma matriz de bytes.

ToUInt64(ReadOnlySpan<Byte>)

Converte bytes em um longo sem sinal.

TryWriteBytes(Span<Byte>, Boolean)

Converte um booliano em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Char)

Converte um caractere em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Double)

Converte um valor de ponto flutuante de precisão dupla em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Half)

Converte um valor de ponto flutuante de meia precisão em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Int128)

Converte um inteiro com sinal de 128 bits em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Int16)

Converte um inteiro com sinal de 16 bits em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Int32)

Converte um inteiro com sinal de 32 bits em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Int64)

Converte um inteiro com sinal de 64 bits em um intervalo de bytes.

TryWriteBytes(Span<Byte>, Single)

Converte um valor de ponto flutuante de precisão única em um intervalo de bytes.

TryWriteBytes(Span<Byte>, UInt128)

Converte um inteiro sem sinal de 128 bits em um intervalo de bytes.

TryWriteBytes(Span<Byte>, UInt16)

Converte um inteiro de 16 bits sem sinal em um intervalo de bytes.

TryWriteBytes(Span<Byte>, UInt32)

Converte um inteiro sem sinal de 32 bits em um intervalo de bytes.

TryWriteBytes(Span<Byte>, UInt64)

Converte um inteiro de 64 bits sem sinal em um intervalo de bytes.

UInt16BitsToHalf(UInt16)

Converte o inteiro sem sinal de 16 bits especificado em um número de ponto flutuante de meia precisão.

UInt32BitsToSingle(UInt32)

Converte o inteiro sem sinal de 32 bits especificado em um número de ponto flutuante de precisão única.

UInt64BitsToDouble(UInt64)

Converte o inteiro sem sinal de 64 bits especificado em um número de ponto flutuante de precisão dupla.

Aplica-se a

Confira também