Byte Estrutura
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Representa um inteiro sem sinal de 8 bits.
public value class System::Byte : IComparable, IComparable<System::Byte>, IConvertible, IEquatable<System::Byte>, IFormattable
public value class System::Byte : IComparable, IComparable<System::Byte>, IConvertible, IEquatable<System::Byte>, ISpanFormattable
public value class System::Byte : IComparable, IConvertible, IFormattable
public value class System::Byte : IComparable, IComparable<System::Byte>, IEquatable<System::Byte>, IFormattable
public struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, IFormattable
public struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, ISpanFormattable
[System.Serializable]
public struct Byte : IComparable, IConvertible, IFormattable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, IFormattable
public struct Byte : IComparable, IComparable<byte>, IEquatable<byte>, IFormattable
type byte = struct
interface IConvertible
interface IFormattable
type byte = struct
interface IConvertible
interface ISpanFormattable
interface IFormattable
[<System.Serializable>]
type byte = struct
interface IFormattable
interface IConvertible
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type byte = struct
interface IFormattable
interface IConvertible
type byte = struct
interface IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IConvertible, IEquatable(Of Byte), IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IConvertible, IEquatable(Of Byte), ISpanFormattable
Public Structure Byte
Implements IComparable, IConvertible, IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IEquatable(Of Byte), IFormattable
- Herança
- Atributos
- Implementações
Comentários
Byte é um tipo de valor imutável que representa inteiros sem sinal com valores que variam de 0 (que é representado pela constante) a 255 (que é representado pela Byte.MinValue Byte.MaxValue constante). O .NET também inclui um tipo de valor inteiro de 8 bits assinado, , que representa valores que variam de SByte -128 a 127.
Criando uma instância de um valor de byte
Você pode insinuar Byte um valor de várias maneiras:
Você pode declarar uma Byte variável e atribuí-la um valor inteiro literal que está dentro do intervalo do tipo Byte de dados. O exemplo a seguir declara duas Byte variáveis e atribui valores dessa maneira.
byte value1 = 64; byte value2 = 255;
let value1 = 64uy let value2 = 255uy
Dim value1 As Byte = 64 Dim value2 As Byte = 255
Você pode atribuir um valor numérico não byte a um byte. Essa é uma conversão de restrição, portanto, requer um operador de conversão em C# e F# ou um método de conversão em Visual Basic se
Option Strict
estiver on. Se o valor não byte for um valor , ou que inclui um componente fracionado, a manipulação de sua parte fracionada dependerá do compilador que executa Single Double a Decimal conversão. O exemplo a seguir atribui vários valores numéricos a Byte variáveis.int int1 = 128; try { byte value1 = (byte) int1; Console.WriteLine(value1); } catch (OverflowException) { Console.WriteLine("{0} is out of range of a byte.", int1); } double dbl2 = 3.997; try { byte value2 = (byte) dbl2; Console.WriteLine(value2); } catch (OverflowException) { Console.WriteLine("{0} is out of range of a byte.", dbl2); } // The example displays the following output: // 128 // 3
let int1 = 128 try let value1 = byte int1 printfn $"{value1}" with :? OverflowException -> printfn $"{int1} is out of range of a byte." let dbl2 = 3.997 try let value2 = byte dbl2 printfn $"{value2}" with :? OverflowException -> printfn $"{dbl2} is out of range of a byte." // The example displays the following output: // 128 // 3
Dim int1 As Integer = 128 Try Dim value1 As Byte = CByte(int1) Console.WriteLine(value1) Catch e As OverflowException Console.WriteLine("{0} is out of range of a byte.", int1) End Try Dim dbl2 As Double = 3.997 Try Dim value2 As Byte = CByte(dbl2) Console.WriteLine(value2) Catch e As OverflowException Console.WriteLine("{0} is out of range of a byte.", dbl2) End Try ' The example displays the following output: ' 128 ' 4
Você pode chamar um método da Convert classe para converter qualquer tipo com suporte em um valor Byte . Isso é possível porque Byte dá suporte à interface IConvertible . O exemplo a seguir ilustra a conversão de uma matriz de Int32 valores em Byte valores .
int[] numbers = { Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue }; byte result; foreach (int number in numbers) { try { result = Convert.ToByte(number); Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", number.GetType().Name, number, result.GetType().Name, result); } catch (OverflowException) { Console.WriteLine("The {0} value {1} is outside the range of the Byte type.", number.GetType().Name, number); } } // The example displays the following output: // The Int32 value -2147483648 is outside the range of the Byte type. // The Int32 value -1 is outside the range of the Byte type. // Converted the Int32 value 0 to the Byte value 0. // Converted the Int32 value 121 to the Byte value 121. // The Int32 value 340 is outside the range of the Byte type. // The Int32 value 2147483647 is outside the range of the Byte type.
open System let numbers = [| Int32.MinValue; -1; 0; 121; 340; Int32.MaxValue |] for number in numbers do try let result = Convert.ToByte number printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}." with :? OverflowException -> printfn $"The {number.GetType().Name} value {number} is outside the range of the Byte type." // The example displays the following output: // The Int32 value -2147483648 is outside the range of the Byte type. // The Int32 value -1 is outside the range of the Byte type. // Converted the Int32 value 0 to the Byte value 0. // Converted the Int32 value 121 to the Byte value 121. // The Int32 value 340 is outside the range of the Byte type. // The Int32 value 2147483647 is outside the range of the Byte type.
Dim numbers() As Integer = { Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue } Dim result As Byte For Each number As Integer In numbers Try result = Convert.ToByte(number) Console.WriteLIne("Converted the {0} value {1} to the {2} value {3}.", _ number.GetType().Name, number, _ result.GetType().Name, result) Catch e As OverflowException Console.WriteLine("The {0} value {1} is outside the range of the Byte type.", _ number.GetType().Name, number) End Try Next ' The example displays the following output: ' The Int32 value -2147483648 is outside the range of the Byte type. ' The Int32 value -1 is outside the range of the Byte type. ' Converted the Int32 value 0 to the Byte value 0. ' Converted the Int32 value 121 to the Byte value 121. ' The Int32 value 340 is outside the range of the Byte type. ' The Int32 value 2147483647 is outside the range of the Byte type.
Você pode chamar o Parse método ou para converter a representação de cadeia de TryParse caracteres de um valor em um Byte Byte . A cadeia de caracteres pode conter dígitos decimais ou hexadecimais. O exemplo a seguir ilustra a operação de análise usando uma cadeia de caracteres decimal e hexadecimal.
string string1 = "244"; try { byte byte1 = Byte.Parse(string1); Console.WriteLine(byte1); } catch (OverflowException) { Console.WriteLine("'{0}' is out of range of a byte.", string1); } catch (FormatException) { Console.WriteLine("'{0}' is out of range of a byte.", string1); } string string2 = "F9"; try { byte byte2 = Byte.Parse(string2, System.Globalization.NumberStyles.HexNumber); Console.WriteLine(byte2); } catch (OverflowException) { Console.WriteLine("'{0}' is out of range of a byte.", string2); } catch (FormatException) { Console.WriteLine("'{0}' is out of range of a byte.", string2); } // The example displays the following output: // 244 // 249
let string1 = "244" try let byte1 = Byte.Parse string1 printfn $"{byte1}" with | :? OverflowException -> printfn $"'{string1}' is out of range of a byte." | :? FormatException -> printfn $"'{string1}' is out of range of a byte." let string2 = "F9" try let byte2 = Byte.Parse(string2, System.Globalization.NumberStyles.HexNumber) printfn $"{byte2}" with | :? OverflowException -> printfn $"'{string2}' is out of range of a byte." | :? FormatException -> printfn $"'{string2}' is out of range of a byte." // The example displays the following output: // 244 // 249
Dim string1 As String = "244" Try Dim byte1 As Byte = Byte.Parse(string1) Console.WriteLine(byte1) Catch e As OverflowException Console.WriteLine("'{0}' is out of range of a byte.", string1) Catch e As FormatException Console.WriteLine("'{0}' is out of range of a byte.", string1) End Try Dim string2 As String = "F9" Try Dim byte2 As Byte = Byte.Parse(string2, System.Globalization.NumberStyles.HexNumber) Console.WriteLine(byte2) Catch e As OverflowException Console.WriteLine("'{0}' is out of range of a byte.", string2) Catch e As FormatException Console.WriteLine("'{0}' is out of range of a byte.", string2) End Try ' The example displays the following output: ' 244 ' 249
Realizando operações em valores de bytes
O Byte tipo dá suporte a operações matemáticas padrão, como adição, subtração, divisão, multiplicação, subtração, negação e negação unária. Assim como os outros tipos integrais, o tipo também dá suporte aos Byte operadores bit a bit AND
, , , shift esquerdo e shift para a OR
XOR
direita.
Você pode usar os operadores numéricos padrão para comparar dois Byte valores ou pode chamar o método ou CompareTo Equals .
Também é possível chamar os membros da classe Math para realizar uma ampla variedade de operações numéricas, inclusive obter o valor absoluto de um número, calcular o quociente e o restante da divisão integral, determinando o valor máximo ou mínimo de dois inteiros, obter o sinal de um número e arredondar um número.
Representando um byte como uma cadeia de caracteres
O Byte tipo fornece suporte completo para cadeias de caracteres de formato numérico padrão e personalizado. (Para obter mais informações, consulte Tipos de formatação,cadeias de caracteresde formato numérico padrão e Cadeias de caracteres de formato numérico personalizado.) No entanto, normalmente, os valores de byte são representados como valores de um dígito a três dígitos sem nenhuma formatação adicional ou como valores hexadecimais de dois dígitos.
Para formatar um Byte valor como uma cadeia de caracteres integral sem zeros à esquerda, você pode chamar o método sem ToString() parâmetros. Usando o especificador de formato "D", você também pode incluir um número especificado de zeros à esquerda na representação de cadeia de caracteres. Usando o especificador de formato "X", você pode representar um Byte valor como uma cadeia de caracteres hexadecimal. O exemplo a seguir formatará os elementos em uma matriz de Byte valores dessas três maneiras.
byte[] numbers = { 0, 16, 104, 213 };
foreach (byte number in numbers) {
// Display value using default formatting.
Console.Write("{0,-3} --> ", number.ToString());
// Display value with 3 digits and leading zeros.
Console.Write(number.ToString("D3") + " ");
// Display value with hexadecimal.
Console.Write(number.ToString("X2") + " ");
// Display value with four hexadecimal digits.
Console.WriteLine(number.ToString("X4"));
}
// The example displays the following output:
// 0 --> 000 00 0000
// 16 --> 016 10 0010
// 104 --> 104 68 0068
// 213 --> 213 D5 00D5
let numbers = [| 0; 16; 104; 213 |]
for number in numbers do
// Display value using default formatting.
number.ToString()
|> printf "%-3s --> "
// Display value with 3 digits and leading zeros.
number.ToString "D3"
|> printf "%s "
// Display value with hexadecimal.
number.ToString "X2"
|> printf "%s "
// Display value with four hexadecimal digits.
number.ToString "X4"
|> printfn "%s"
// The example displays the following output:
// 0 --> 000 00 0000
// 16 --> 016 10 0010
// 104 --> 104 68 0068
// 213 --> 213 D5 00D5
Dim numbers() As Byte = { 0, 16, 104, 213 }
For Each number As Byte In numbers
' Display value using default formatting.
Console.Write("{0,-3} --> ", number.ToString())
' Display value with 3 digits and leading zeros.
Console.Write(number.ToString("D3") + " ")
' Display value with hexadecimal.
Console.Write(number.ToString("X2") + " ")
' Display value with four hexadecimal digits.
Console.WriteLine(number.ToString("X4"))
Next
' The example displays the following output:
' 0 --> 000 00 0000
' 16 --> 016 10 0010
' 104 --> 104 68 0068
' 213 --> 213 D5 00D5
Você também pode formatar um valor como uma cadeia de caracteres binária, octal, decimal ou hexadecimal chamando o método e fornecendo a base como o segundo parâmetro do Byte ToString(Byte, Int32) método. O exemplo a seguir chama esse método para exibir as representações binárias, octais e hexadecimais de uma matriz de valores de byte.
byte[] numbers ={ 0, 16, 104, 213 };
Console.WriteLine("{0} {1,8} {2,5} {3,5}",
"Value", "Binary", "Octal", "Hex");
foreach (byte number in numbers) {
Console.WriteLine("{0,5} {1,8} {2,5} {3,5}",
number, Convert.ToString(number, 2),
Convert.ToString(number, 8),
Convert.ToString(number, 16));
}
// The example displays the following output:
// Value Binary Octal Hex
// 0 0 0 0
// 16 10000 20 10
// 104 1101000 150 68
// 213 11010101 325 d5
let numbers = [| 0; 16; 104; 213 |]
printfn "%s %8s %5s %5s" "Value" "Binary" "Octal" "Hex"
for number in numbers do
printfn $"%5i{number} %8s{Convert.ToString(number, 2)} %5s{Convert.ToString(number, 8)} %5s{Convert.ToString(number, 16)}"
// The example displays the following output:
// Value Binary Octal Hex
// 0 0 0 0
// 16 10000 20 10
// 104 1101000 150 68
// 213 11010101 325 d5
Dim numbers() As Byte = { 0, 16, 104, 213 }
Console.WriteLine("{0} {1,8} {2,5} {3,5}", _
"Value", "Binary", "Octal", "Hex")
For Each number As Byte In numbers
Console.WriteLine("{0,5} {1,8} {2,5} {3,5}", _
number, Convert.ToString(number, 2), _
Convert.ToString(number, 8), _
Convert.ToString(number, 16))
Next
' The example displays the following output:
' Value Binary Octal Hex
' 0 0 0 0
' 16 10000 20 10
' 104 1101000 150 68
' 213 11010101 325 d5
Trabalhando com valores de byte não decimal
Além de trabalhar com bytes individuais como valores decimais, talvez você queira executar operações bit a bit com valores de bytes ou trabalhar com matrizes de bytes ou com as representações binárias ou hexadecimais de valores de bytes. Por exemplo, sobrecargas do método podem converter cada um dos tipos de dados primitivos em uma matriz de byte e o método converte um valor em uma matriz BitConverter.GetBytes BigInteger.ToByteArray de BigInteger byte.
Byte os valores são representados em 8 bits apenas por sua magnitude, sem um bit de sinal. Isso é importante ter em mente quando você executa operações bit a bit em valores Byte ou quando trabalha com bits individuais. Para executar uma operação numérica, booliana ou de comparação em dois valores não decimais, ambos os valores devem usar a mesma representação.
Quando uma operação é executada em dois valores, os valores compartilham a Byte mesma representação, portanto, o resultado é preciso. Isso é ilustrado no exemplo a seguir, que mascara o bit de ordem mais baixa de um valor para Byte garantir que ele seja o mesmo.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
string[] values = { Convert.ToString(12, 16),
Convert.ToString(123, 16),
Convert.ToString(245, 16) };
byte mask = 0xFE;
foreach (string value in values) {
Byte byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier);
Console.WriteLine("{0} And {1} = {2}", byteValue, mask,
byteValue & mask);
}
}
}
// The example displays the following output:
// 12 And 254 = 12
// 123 And 254 = 122
// 245 And 254 = 244
open System
open System.Globalization
let values =
[ Convert.ToString(12, 16)
Convert.ToString(123, 16)
Convert.ToString(245, 16) ]
let mask = 0xFEuy
for value in values do
let byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier)
printfn $"{byteValue} And {mask} = {byteValue &&& mask}"
// The example displays the following output:
// 12 And 254 = 12
// 123 And 254 = 122
// 245 And 254 = 244
Imports System.Globalization
Module Example
Public Sub Main()
Dim values() As String = { Convert.ToString(12, 16), _
Convert.ToString(123, 16), _
Convert.ToString(245, 16) }
Dim mask As Byte = &hFE
For Each value As String In values
Dim byteValue As Byte = Byte.Parse(value, NumberStyles.AllowHexSpecifier)
Console.WriteLine("{0} And {1} = {2}", byteValue, mask, _
byteValue And mask)
Next
End Sub
End Module
' The example displays the following output:
' 12 And 254 = 12
' 123 And 254 = 122
' 245 And 254 = 244
Por outro lado, quando você trabalha com bits sem sinal e assinados, as operações bit a bit são complicadas pelo fato de que os valores usam representação de sinal e magnitude para valores positivos e a representação complementar de dois para valores SByte negativos. Para executar uma operação bit a bit significativa, os valores devem ser convertidos em duas representações equivalentes e as informações sobre o bit de sinal devem ser preservadas. O exemplo a seguir faz isso para mascarar os bits 2 e 4 de uma matriz de valores assinados e não assinados de 8 bits.
using System;
using System.Collections.Generic;
using System.Globalization;
public struct ByteString
{
public string Value;
public int Sign;
}
public class Example
{
public static void Main()
{
ByteString[] values = CreateArray(-15, 123, 245);
byte mask = 0x14; // Mask all bits but 2 and 4.
foreach (ByteString strValue in values) {
byte byteValue = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier);
Console.WriteLine("{0} ({1}) And {2} ({3}) = {4} ({5})",
strValue.Sign * byteValue,
Convert.ToString(byteValue, 2),
mask, Convert.ToString(mask, 2),
(strValue.Sign & Math.Sign(mask)) * (byteValue & mask),
Convert.ToString(byteValue & mask, 2));
}
}
private static ByteString[] CreateArray(params int[] values)
{
List<ByteString> byteStrings = new List<ByteString>();
foreach (object value in values) {
ByteString temp = new ByteString();
int sign = Math.Sign((int) value);
temp.Sign = sign;
// Change two's complement to magnitude-only representation.
temp.Value = Convert.ToString(((int) value) * sign, 16);
byteStrings.Add(temp);
}
return byteStrings.ToArray();
}
}
// The example displays the following output:
// -15 (1111) And 20 (10100) = 4 (100)
// 123 (1111011) And 20 (10100) = 16 (10000)
// 245 (11110101) And 20 (10100) = 20 (10100)
open System
open System.Collections.Generic
open System.Globalization
[<Struct>]
type ByteString =
{ Sign: int
Value: string }
let createArray values =
[ for value in values do
let sign = sign value
{ Sign = sign
// Change two's complement to magnitude-only representation.
Value = Convert.ToString(value * sign, 16)} ]
let values = createArray [ -15; 123; 245 ]
let mask = 0x14uy // Mask all bits but 2 and 4.
for strValue in values do
let byteValue = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier)
printfn $"{strValue.Sign * int byteValue} ({Convert.ToString(byteValue, 2)}) And {mask} ({Convert.ToString(mask, 2)}) = {(strValue.Sign &&& (int mask |> sign)) * int (byteValue &&& mask)} ({Convert.ToString(byteValue &&& mask, 2)})"
// The example displays the following output:
// -15 (1111) And 20 (10100) = 4 (100)
// 123 (1111011) And 20 (10100) = 16 (10000)
// 245 (11110101) And 20 (10100) = 20 (10100)
Imports System.Collections.Generic
Imports System.Globalization
Public Structure ByteString
Public Value As String
Public Sign As Integer
End Structure
Module Example
Public Sub Main()
Dim values() As ByteString = CreateArray(-15, 123, 245)
Dim mask As Byte = &h14 ' Mask all bits but 2 and 4.
For Each strValue As ByteString In values
Dim byteValue As Byte = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier)
Console.WriteLine("{0} ({1}) And {2} ({3}) = {4} ({5})", _
strValue.Sign * byteValue, _
Convert.ToString(byteValue, 2), _
mask, Convert.ToString(mask, 2), _
(strValue.Sign And Math.Sign(mask)) * (byteValue And mask), _
Convert.ToString(byteValue And mask, 2))
Next
End Sub
Private Function CreateArray(ParamArray values() As Object) As ByteString()
Dim byteStrings As New List(Of ByteString)
For Each value As Object In values
Dim temp As New ByteString()
Dim sign As Integer = Math.Sign(value)
temp.Sign = sign
' Change two's complement to magnitude-only representation.
value = value * sign
temp.Value = Convert.ToString(value, 16)
byteStrings.Add(temp)
Next
Return byteStrings.ToArray()
End Function
End Module
' The example displays the following output:
' -15 (1111) And 20 (10100) = 4 (100)
' 123 (1111011) And 20 (10100) = 16 (10000)
' 245 (11110101) And 20 (10100) = 20 (10100)
Campos
MaxValue |
Representa o maior valor possível de um Byte. Este campo é constante. |
MinValue |
Representa o menor valor possível de um Byte. Este campo é constante. |
Métodos
CompareTo(Byte) |
Compara essa instância com um inteiro sem sinal de 8 bits especificado e retorna uma indicação dos valores relativos. |
CompareTo(Object) |
Compara essa instância com um objeto especificado e retorna uma indicação dos valores relativos. |
Equals(Byte) |
Retorna um valor que indica se essa instância e um objeto Byte especificado representam o mesmo valor. |
Equals(Object) |
Retorna um valor que indica se a instância é igual a um objeto especificado. |
GetHashCode() |
Retorna o código hash para a instância. |
GetTypeCode() | |
Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) |
Converte a representação de intervalo de um número com um estilo especificado e um formato específico à cultura para seu Byte equivalente. |
Parse(String) |
Converte a representação da cadeia de caracteres de um número no Byte equivalente. |
Parse(String, IFormatProvider) |
Converte a representação de cadeia de caracteres de um número em um formato específico da cultura especificado em seu equivalente de Byte. |
Parse(String, NumberStyles) |
Converte a representação de cadeia de caracteres de um número em um estilo especificado em seu Byte equivalente. |
Parse(String, NumberStyles, IFormatProvider) |
Converte a representação de cadeia de caracteres de um número com um estilo especificado e um formato específico à cultura para seu Byte equivalente. |
ToString() |
Converte o valor do atual objeto Byte na representação de cadeia de caracteres equivalente. |
ToString(IFormatProvider) |
Converte o valor numérico do objeto Byte atual em sua representação de cadeia de caracteres equivalente usando as informações de formatação específicas da cultura especificada. |
ToString(String) |
Converte o valor do objeto Byte atual em sua representação de cadeia de caracteres equivalente usando o formato especificado. |
ToString(String, IFormatProvider) |
Converte o valor do objeto Byte atual na representação de cadeia de caracteres equivalente usando o formato especificado e as informações de formatação específicas da cultura. |
TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
Tenta formatar o valor da instância de inteiro sem sinal de 8 bits atual no intervalo de caracteres fornecido. |
TryParse(ReadOnlySpan<Char>, Byte) |
Tenta converter a representação de intervalo de um número em seu Byte equivalente e retorna um valor que indica se a conversão foi bem-sucedida. |
TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, Byte) |
Converte a representação de intervalo de um número com um estilo especificado e um formato específico à cultura para seu Byte equivalente. Um valor retornado indica se a conversão foi bem-sucedida ou falhou. |
TryParse(String, Byte) |
Tenta converter a representação de cadeia de caracteres de um número em seu Byte equivalente e retorna um valor que indica se a conversão foi bem-sucedida. |
TryParse(String, NumberStyles, IFormatProvider, Byte) |
Converte a representação de cadeia de caracteres de um número com um estilo especificado e um formato específico à cultura para seu Byte equivalente. Um valor retornado indica se a conversão foi bem-sucedida ou falhou. |
Implantações explícitas de interface
IComparable.CompareTo(Object) |
Compara a instância atual com outro objeto do mesmo tipo e retorna um inteiro que indica se a instância atual precede, segue ou ocorre na mesma posição da ordem de classificação do outro objeto. |
IConvertible.GetTypeCode() |
Retorna o TypeCode para essa instância. |
IConvertible.ToBoolean(IFormatProvider) |
Para obter uma descrição desse membro, confira ToBoolean(IFormatProvider). |
IConvertible.ToByte(IFormatProvider) |
Para obter uma descrição desse membro, confira ToByte(IFormatProvider). |
IConvertible.ToChar(IFormatProvider) |
Para obter uma descrição desse membro, confira ToChar(IFormatProvider). |
IConvertible.ToDateTime(IFormatProvider) |
Não há suporte para esta conversão. A tentativa de usar esse método lança um InvalidCastException. |
IConvertible.ToDecimal(IFormatProvider) |
Para obter uma descrição desse membro, confira ToDecimal(IFormatProvider). |
IConvertible.ToDouble(IFormatProvider) |
Para obter uma descrição desse membro, confira ToDouble(IFormatProvider). |
IConvertible.ToInt16(IFormatProvider) |
Para obter uma descrição desse membro, confira ToInt16(IFormatProvider). |
IConvertible.ToInt32(IFormatProvider) |
Para obter uma descrição desse membro, confira ToInt32(IFormatProvider). |
IConvertible.ToInt64(IFormatProvider) |
Para obter uma descrição desse membro, confira ToInt64(IFormatProvider). |
IConvertible.ToSByte(IFormatProvider) |
Para obter uma descrição desse membro, confira ToSByte(IFormatProvider). |
IConvertible.ToSingle(IFormatProvider) |
Para obter uma descrição desse membro, confira ToSingle(IFormatProvider). |
IConvertible.ToType(Type, IFormatProvider) |
Para obter uma descrição desse membro, confira ToType(Type, IFormatProvider). |
IConvertible.ToUInt16(IFormatProvider) |
Para obter uma descrição desse membro, confira ToUInt16(IFormatProvider). |
IConvertible.ToUInt32(IFormatProvider) |
Para obter uma descrição desse membro, confira ToUInt32(IFormatProvider). |
IConvertible.ToUInt64(IFormatProvider) |
Para obter uma descrição desse membro, confira ToUInt64(IFormatProvider). |
Aplica-se a
Acesso thread-safe
Todos os membros desse tipo são thread-safe. Os membros que aparentam modificar efetivamente o estado retornam uma nova instância inicializada com o novo valor. Assim como acontece com qualquer outro tipo, a leitura e a gravação em uma variável compartilhada que contém uma instância desse tipo devem ser protegidas por um bloqueio para garantir thread-safe.