Byte Estrutura
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
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<System::Byte>, IConvertible, IEquatable<System::Byte>, IParsable<System::Byte>, ISpanParsable<System::Byte>, IUtf8SpanParsable<System::Byte>, System::Numerics::IAdditionOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IAdditiveIdentity<System::Byte, System::Byte>, System::Numerics::IBinaryInteger<System::Byte>, System::Numerics::IBinaryNumber<System::Byte>, System::Numerics::IBitwiseOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IComparisonOperators<System::Byte, System::Byte, bool>, System::Numerics::IDecrementOperators<System::Byte>, System::Numerics::IDivisionOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IEqualityOperators<System::Byte, System::Byte, bool>, System::Numerics::IIncrementOperators<System::Byte>, System::Numerics::IMinMaxValue<System::Byte>, System::Numerics::IModulusOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IMultiplicativeIdentity<System::Byte, System::Byte>, System::Numerics::IMultiplyOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::INumber<System::Byte>, System::Numerics::INumberBase<System::Byte>, System::Numerics::IShiftOperators<System::Byte, int, System::Byte>, System::Numerics::ISubtractionOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IUnaryNegationOperators<System::Byte, System::Byte>, System::Numerics::IUnaryPlusOperators<System::Byte, System::Byte>, System::Numerics::IUnsignedNumber<System::Byte>
public value class System::Byte : IComparable, IComparable<System::Byte>, IConvertible, IEquatable<System::Byte>, ISpanFormattable
public value class System::Byte : IComparable<System::Byte>, IConvertible, IEquatable<System::Byte>, IParsable<System::Byte>, ISpanParsable<System::Byte>, System::Numerics::IAdditionOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IAdditiveIdentity<System::Byte, System::Byte>, System::Numerics::IBinaryInteger<System::Byte>, System::Numerics::IBinaryNumber<System::Byte>, System::Numerics::IBitwiseOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IComparisonOperators<System::Byte, System::Byte, bool>, System::Numerics::IDecrementOperators<System::Byte>, System::Numerics::IDivisionOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IEqualityOperators<System::Byte, System::Byte, bool>, System::Numerics::IIncrementOperators<System::Byte>, System::Numerics::IMinMaxValue<System::Byte>, System::Numerics::IModulusOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IMultiplicativeIdentity<System::Byte, System::Byte>, System::Numerics::IMultiplyOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::INumber<System::Byte>, System::Numerics::INumberBase<System::Byte>, System::Numerics::IShiftOperators<System::Byte, int, System::Byte>, System::Numerics::ISubtractionOperators<System::Byte, System::Byte, System::Byte>, System::Numerics::IUnaryNegationOperators<System::Byte, System::Byte>, System::Numerics::IUnaryPlusOperators<System::Byte, System::Byte>, System::Numerics::IUnsignedNumber<System::Byte>
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 readonly struct Byte : IComparable<byte>, IConvertible, IEquatable<byte>, IParsable<byte>, ISpanParsable<byte>, IUtf8SpanParsable<byte>, System.Numerics.IAdditionOperators<byte,byte,byte>, System.Numerics.IAdditiveIdentity<byte,byte>, System.Numerics.IBinaryInteger<byte>, System.Numerics.IBinaryNumber<byte>, System.Numerics.IBitwiseOperators<byte,byte,byte>, System.Numerics.IComparisonOperators<byte,byte,bool>, System.Numerics.IDecrementOperators<byte>, System.Numerics.IDivisionOperators<byte,byte,byte>, System.Numerics.IEqualityOperators<byte,byte,bool>, System.Numerics.IIncrementOperators<byte>, System.Numerics.IMinMaxValue<byte>, System.Numerics.IModulusOperators<byte,byte,byte>, System.Numerics.IMultiplicativeIdentity<byte,byte>, System.Numerics.IMultiplyOperators<byte,byte,byte>, System.Numerics.INumber<byte>, System.Numerics.INumberBase<byte>, System.Numerics.IShiftOperators<byte,int,byte>, System.Numerics.ISubtractionOperators<byte,byte,byte>, System.Numerics.IUnaryNegationOperators<byte,byte>, System.Numerics.IUnaryPlusOperators<byte,byte>, System.Numerics.IUnsignedNumber<byte>
public readonly struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, IFormattable
public readonly struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, ISpanFormattable
public readonly struct Byte : IComparable<byte>, IConvertible, IEquatable<byte>, IParsable<byte>, ISpanParsable<byte>, System.Numerics.IAdditionOperators<byte,byte,byte>, System.Numerics.IAdditiveIdentity<byte,byte>, System.Numerics.IBinaryInteger<byte>, System.Numerics.IBinaryNumber<byte>, System.Numerics.IBitwiseOperators<byte,byte,byte>, System.Numerics.IComparisonOperators<byte,byte,bool>, System.Numerics.IDecrementOperators<byte>, System.Numerics.IDivisionOperators<byte,byte,byte>, System.Numerics.IEqualityOperators<byte,byte,bool>, System.Numerics.IIncrementOperators<byte>, System.Numerics.IMinMaxValue<byte>, System.Numerics.IModulusOperators<byte,byte,byte>, System.Numerics.IMultiplicativeIdentity<byte,byte>, System.Numerics.IMultiplyOperators<byte,byte,byte>, System.Numerics.INumber<byte>, System.Numerics.INumberBase<byte>, System.Numerics.IShiftOperators<byte,int,byte>, System.Numerics.ISubtractionOperators<byte,byte,byte>, System.Numerics.IUnaryNegationOperators<byte,byte>, System.Numerics.IUnaryPlusOperators<byte,byte>, System.Numerics.IUnsignedNumber<byte>
[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 IFormattable
interface IParsable<byte>
interface ISpanFormattable
interface ISpanParsable<byte>
interface IUtf8SpanFormattable
interface IUtf8SpanParsable<byte>
interface IAdditionOperators<byte, byte, byte>
interface IAdditiveIdentity<byte, byte>
interface IBinaryInteger<byte>
interface IBinaryNumber<byte>
interface IBitwiseOperators<byte, byte, byte>
interface IComparisonOperators<byte, byte, bool>
interface IEqualityOperators<byte, byte, bool>
interface IDecrementOperators<byte>
interface IDivisionOperators<byte, byte, byte>
interface IIncrementOperators<byte>
interface IModulusOperators<byte, byte, byte>
interface IMultiplicativeIdentity<byte, byte>
interface IMultiplyOperators<byte, byte, byte>
interface INumber<byte>
interface INumberBase<byte>
interface ISubtractionOperators<byte, byte, byte>
interface IUnaryNegationOperators<byte, byte>
interface IUnaryPlusOperators<byte, byte>
interface IShiftOperators<byte, int, byte>
interface IMinMaxValue<byte>
interface IUnsignedNumber<byte>
type byte = struct
interface IConvertible
interface ISpanFormattable
interface IFormattable
type byte = struct
interface IConvertible
interface IFormattable
interface IParsable<byte>
interface ISpanFormattable
interface ISpanParsable<byte>
interface IAdditionOperators<byte, byte, byte>
interface IAdditiveIdentity<byte, byte>
interface IBinaryInteger<byte>
interface IBinaryNumber<byte>
interface IBitwiseOperators<byte, byte, byte>
interface IComparisonOperators<byte, byte, bool>
interface IEqualityOperators<byte, byte, bool>
interface IDecrementOperators<byte>
interface IDivisionOperators<byte, byte, byte>
interface IIncrementOperators<byte>
interface IModulusOperators<byte, byte, byte>
interface IMultiplicativeIdentity<byte, byte>
interface IMultiplyOperators<byte, byte, byte>
interface INumber<byte>
interface INumberBase<byte>
interface ISubtractionOperators<byte, byte, byte>
interface IUnaryNegationOperators<byte, byte>
interface IUnaryPlusOperators<byte, byte>
interface IShiftOperators<byte, int, byte>
interface IMinMaxValue<byte>
interface IUnsignedNumber<byte>
type byte = struct
interface IConvertible
interface IFormattable
interface IParsable<byte>
interface ISpanFormattable
interface ISpanParsable<byte>
interface IAdditionOperators<byte, byte, byte>
interface IAdditiveIdentity<byte, byte>
interface IBinaryInteger<byte>
interface IBinaryNumber<byte>
interface IBitwiseOperators<byte, byte, byte>
interface IComparisonOperators<byte, byte, bool>
interface IEqualityOperators<byte, byte, bool>
interface IDecrementOperators<byte>
interface IDivisionOperators<byte, byte, byte>
interface IIncrementOperators<byte>
interface IModulusOperators<byte, byte, byte>
interface IMultiplicativeIdentity<byte, byte>
interface IMultiplyOperators<byte, byte, byte>
interface INumber<byte>
interface INumberBase<byte>
interface ISubtractionOperators<byte, byte, byte>
interface IUnaryNegationOperators<byte, byte>
interface IUnaryPlusOperators<byte, byte>
interface IUtf8SpanFormattable
interface IUtf8SpanParsable<byte>
interface IShiftOperators<byte, int, byte>
interface IMinMaxValue<byte>
interface IUnsignedNumber<byte>
[<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 IAdditionOperators(Of Byte, Byte, Byte), IAdditiveIdentity(Of Byte, Byte), IBinaryInteger(Of Byte), IBinaryNumber(Of Byte), IBitwiseOperators(Of Byte, Byte, Byte), IComparable(Of Byte), IComparisonOperators(Of Byte, Byte, Boolean), IConvertible, IDecrementOperators(Of Byte), IDivisionOperators(Of Byte, Byte, Byte), IEqualityOperators(Of Byte, Byte, Boolean), IEquatable(Of Byte), IIncrementOperators(Of Byte), IMinMaxValue(Of Byte), IModulusOperators(Of Byte, Byte, Byte), IMultiplicativeIdentity(Of Byte, Byte), IMultiplyOperators(Of Byte, Byte, Byte), INumber(Of Byte), INumberBase(Of Byte), IParsable(Of Byte), IShiftOperators(Of Byte, Integer, Byte), ISpanParsable(Of Byte), ISubtractionOperators(Of Byte, Byte, Byte), IUnaryNegationOperators(Of Byte, Byte), IUnaryPlusOperators(Of Byte, Byte), IUnsignedNumber(Of Byte), IUtf8SpanParsable(Of Byte)
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IConvertible, IEquatable(Of Byte), ISpanFormattable
Public Structure Byte
Implements IAdditionOperators(Of Byte, Byte, Byte), IAdditiveIdentity(Of Byte, Byte), IBinaryInteger(Of Byte), IBinaryNumber(Of Byte), IBitwiseOperators(Of Byte, Byte, Byte), IComparable(Of Byte), IComparisonOperators(Of Byte, Byte, Boolean), IConvertible, IDecrementOperators(Of Byte), IDivisionOperators(Of Byte, Byte, Byte), IEqualityOperators(Of Byte, Byte, Boolean), IEquatable(Of Byte), IIncrementOperators(Of Byte), IMinMaxValue(Of Byte), IModulusOperators(Of Byte, Byte, Byte), IMultiplicativeIdentity(Of Byte, Byte), IMultiplyOperators(Of Byte, Byte, Byte), INumber(Of Byte), INumberBase(Of Byte), IParsable(Of Byte), IShiftOperators(Of Byte, Integer, Byte), ISpanParsable(Of Byte), ISubtractionOperators(Of Byte, Byte, Byte), IUnaryNegationOperators(Of Byte, Byte), IUnaryPlusOperators(Of Byte, Byte), IUnsignedNumber(Of Byte)
Public Structure Byte
Implements IComparable, IConvertible, IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IEquatable(Of Byte), IFormattable
- Herança
- Atributos
- Implementações
-
IComparable IComparable<Byte> IConvertible IEquatable<Byte> IFormattable IComparable<TSelf> IEquatable<TSelf> IParsable<Byte> IParsable<TSelf> ISpanFormattable ISpanParsable<Byte> ISpanParsable<TSelf> IUtf8SpanFormattable IUtf8SpanParsable<Byte> IUtf8SpanParsable<TSelf> IAdditionOperators<Byte,Byte,Byte> IAdditionOperators<TSelf,TSelf,TSelf> IAdditiveIdentity<Byte,Byte> IAdditiveIdentity<TSelf,TSelf> IBinaryInteger<Byte> IBinaryNumber<Byte> IBinaryNumber<TSelf> IBitwiseOperators<Byte,Byte,Byte> IBitwiseOperators<TSelf,TSelf,TSelf> IComparisonOperators<Byte,Byte,Boolean> IComparisonOperators<TSelf,TSelf,Boolean> IDecrementOperators<Byte> IDecrementOperators<TSelf> IDivisionOperators<Byte,Byte,Byte> IDivisionOperators<TSelf,TSelf,TSelf> IEqualityOperators<Byte,Byte,Boolean> IEqualityOperators<TSelf,TOther,TResult> IEqualityOperators<TSelf,TSelf,Boolean> IIncrementOperators<Byte> IIncrementOperators<TSelf> IMinMaxValue<Byte> IModulusOperators<Byte,Byte,Byte> IModulusOperators<TSelf,TSelf,TSelf> IMultiplicativeIdentity<Byte,Byte> IMultiplicativeIdentity<TSelf,TSelf> IMultiplyOperators<Byte,Byte,Byte> IMultiplyOperators<TSelf,TSelf,TSelf> INumber<Byte> INumber<TSelf> INumberBase<Byte> INumberBase<TSelf> IShiftOperators<Byte,Int32,Byte> IShiftOperators<TSelf,Int32,TSelf> ISubtractionOperators<Byte,Byte,Byte> ISubtractionOperators<TSelf,TSelf,TSelf> IUnaryNegationOperators<Byte,Byte> IUnaryNegationOperators<TSelf,TSelf> IUnaryPlusOperators<Byte,Byte> IUnaryPlusOperators<TSelf,TSelf> IUnsignedNumber<Byte>
Observações
Byte é um tipo de valor imutável que representa inteiros não assinados com valores que variam de 0 (que é representado pela constante Byte.MinValue) a 255 (que é representado pela constante Byte.MaxValue). O .NET também inclui um tipo de valor inteiro de 8 bits assinado, SByte, que representa valores que variam de -128 a 127.
Instanciar um valor de Byte
Você pode instanciar um valor de Byte de várias maneiras:
Você pode declarar uma variável Byte e atribuir-lhe um valor inteiro literal que esteja dentro do intervalo do tipo de dados Byte. O exemplo a seguir declara duas variáveis Byte e atribui-lhes valores dessa maneira.
byte value1 = 64; byte value2 = 255;let value1 = 64uy let value2 = 255uyDim value1 As Byte = 64 Dim value2 As Byte = 255Você pode atribuir um valor numérico não-byte a um byte. Esta é uma conversão de estreitamento, portanto, requer um operador cast em C# e F#, ou um método de conversão no Visual Basic se
Option Strictestiver ativado. Se o valor não-byte for um valor Single, Doubleou Decimal que inclua um componente fracionário, a manipulação de sua parte fracionária dependerá do compilador que executa a 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($"{int1} is out of range of a byte."); } double dbl2 = 3.997; try { byte value2 = (byte)dbl2; Console.WriteLine(value2); } catch (OverflowException) { Console.WriteLine($"{dbl2} is out of range of a byte."); } // The example displays the following output: // 128 // 3let 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 // 3Dim 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 ' 4Você pode chamar um método da classe Convert para converter qualquer tipo suportado em um valor Byte. Isso é possível porque Byte suporta a interface IConvertible. O exemplo a seguir ilustra a conversão de uma matriz de valores de Int32 em valores Byte.
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.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 método Parse ou TryParse para converter a representação de cadeia de caracteres de um valor Byte em um 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 decimal e uma cadeia hexadecimal.
string string1 = "244"; try { byte byte1 = Byte.Parse(string1); Console.WriteLine(byte1); } catch (OverflowException) { Console.WriteLine($"'{string1}' is out of range of a byte."); } catch (FormatException) { Console.WriteLine($"'{string1}' is out of range of a byte."); } string string2 = "F9"; try { byte byte2 = Byte.Parse(string2, System.Globalization.NumberStyles.HexNumber); Console.WriteLine(byte2); } catch (OverflowException) { Console.WriteLine($"'{string2}' is out of range of a byte."); } catch (FormatException) { Console.WriteLine($"'{string2}' is out of range of a byte."); } // The example displays the following output: // 244 // 249let 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 // 249Dim 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
Executar operações em valores de Byte
O tipo Byte suporta operações matemáticas padrão, como adição, subtração, divisão, multiplicação, subtração, negação e negação unária. Como os outros tipos integrais, o tipo Byte também suporta os operadores bitwise AND, OR, XOR, deslocamento à esquerda e deslocamento à direita.
Você pode usar os operadores numéricos padrão para comparar dois valores Byte ou pode chamar o método CompareTo ou Equals.
Você também pode chamar os membros da classe Math para executar uma ampla gama de operações numéricas, incluindo obter o valor absoluto de um número, calcular o quociente e o restante da divisão integral, determinar o valor máximo ou mínimo de dois inteiros, obter o sinal de um número e arredondar um número.
Representar um byte como uma cadeia de caracteres
O tipo Byte fornece suporte total para cadeias de caracteres de formato numérico padrão e personalizado. (Para obter mais informações, consulte Tipos de formatação, Cadeias de caracteres de formato numérico padrãoe Cadeias de caracteres de formato numérico personalizado.) No entanto, mais comumente, os valores de byte são representados como valores de um dígito a três dígitos sem qualquer formatação adicional, ou como valores hexadecimais de dois dígitos.
Para formatar um valor Byte como uma cadeia de caracteres integral sem zeros à esquerda, você pode chamar o método ToString() sem parâmetros. Usando o especificador de formato "D", você também pode incluir um número especificado de zeros à esquerda na representação da cadeia de caracteres. Usando o especificador de formato "X", você pode representar um valor Byte como uma cadeia de caracteres hexadecimal. O exemplo a seguir formata os elementos em uma matriz de valores de Byte 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 Byte como uma cadeia de caracteres binária, octal, decimal ou hexadecimal chamando o método ToString(Byte, Int32) e fornecendo a base como o segundo parâmetro do 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
Trabalhar com valores de Byte não decimais
Além de trabalhar com bytes individuais como valores decimais, convém executar operações bit a bit com valores de byte ou trabalhar com matrizes de bytes ou com representações binárias ou hexadecimais de valores de bytes. Por exemplo, sobrecargas do método BitConverter.GetBytes podem converter cada um dos tipos de dados primitivos em uma matriz de bytes, e o método BigInteger.ToByteArray converte um valor BigInteger em uma matriz de bytes.
Byte valores são representados em 8 bits apenas pela 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, booleana ou de comparação em quaisquer dois valores não decimais, ambos os valores devem usar a mesma representação.
Quando uma operação é executada em dois Byte valores, os valores compartilham a mesma representação, portanto, o resultado é preciso. Isso é ilustrado no exemplo a seguir, que mascara o bit de ordem mais baixa de um valor Byte para garantir que ele seja uniforme.
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($"{byteValue} And {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 Example1
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 se trabalha com bits não assinados e assinados, as operações bit a bit são complicadas pelo facto de os valores SByte utilizarem a representação de sinal e magnitude para valores positivos, e a representação de complemento de dois para valores 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 BSExample1
{
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($"{strValue.Sign * byteValue} ({Convert.ToString(byteValue, 2)}) And {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();
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 Example2
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
| Name | Descrição |
|---|---|
| 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
| Name | Descrição |
|---|---|
| Clamp(Byte, Byte, Byte) |
Fixa um valor a um valor mínimo e máximo inclusivo. |
| CompareTo(Byte) |
Compara esta instância com um inteiro não assinado especificado de 8 bits e devolve uma indicação dos seus valores relativos. |
| CompareTo(Object) |
Compara esta instância com um objeto especificado e devolve uma indicação dos seus valores relativos. |
| CreateChecked<TOther>(TOther) |
Cria uma instância do tipo atual a partir de um valor, lançando uma exceção de overflow para quaisquer valores que estejam fora do intervalo representável do tipo atual. |
| CreateSaturating<TOther>(TOther) |
Cria uma instância do tipo atual a partir de um valor, saturando quaisquer valores que estejam fora do intervalo representável do tipo atual. |
| CreateTruncating<TOther>(TOther) |
Cria uma instância do tipo atual a partir de um valor, truncando quaisquer valores que estejam fora do intervalo representável do tipo atual. |
| DivRem(Byte, Byte) |
Calcula o quociente e o resto de dois valores. |
| Equals(Byte) |
Devolve um valor que indica se esta instância e um objeto especificado Byte representam o mesmo valor. |
| Equals(Object) |
Devolve um valor que indica se esta instância é igual a um objeto especificado. |
| GetHashCode() |
Devolve o código de hash para esta instância. |
| GetTypeCode() | |
| IsEvenInteger(Byte) |
Determina se um valor representa um número inteiro par. |
| IsOddInteger(Byte) |
Determina se um valor representa um número inteiro ímpar. |
| IsPow2(Byte) |
Determina se um valor é uma potência de dois. |
| LeadingZeroCount(Byte) |
Calcula o número de zeros à esquerda num valor. |
| Log10(Byte) |
Representa um inteiro sem sinal de 8 bits. |
| Log2(Byte) |
Calcula o log2 de um valor. |
| Max(Byte, Byte) |
Compara dois valores para calcular qual é maior. |
| Min(Byte, Byte) |
Compara dois valores para calcular qual é menor. |
| Parse(ReadOnlySpan<Byte>, IFormatProvider) |
Analisa um intervalo de caracteres UTF-8 num valor. |
| Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider) |
Analisa um intervalo de caracteres UTF-8 num valor. |
| Parse(ReadOnlySpan<Char>, IFormatProvider) |
Divide um intervalo de caracteres num valor. |
| Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider) |
Converte a representação span de um número num estilo especificado e formato específico de cultura para o seu Byte equivalente. |
| Parse(String, IFormatProvider) |
Converte a representação da cadeia de um número num formato específico de cultura para o seu Byte equivalente. |
| Parse(String, NumberStyles, IFormatProvider) |
Converte a representação em cadeia de um número num estilo especificado e formato específico de cultura para o seu Byte equivalente. |
| Parse(String, NumberStyles) |
Converte a representação da cadeia de um número num estilo especificado para o seu Byte equivalente. |
| Parse(String) |
Converte a representação da cadeia de um número para o seu Byte equivalente. |
| PopCount(Byte) |
Calcula o número de bits que estão definidos num valor. |
| RotateLeft(Byte, Int32) |
Roda um valor deixado por uma determinada quantia. |
| RotateRight(Byte, Int32) |
Roda um valor exatamente por uma determinada quantia. |
| Sign(Byte) |
Calcula o sinal de um valor. |
| ToString() |
Converte o valor do objeto atual Byte para a sua representação equivalente em cadeias. |
| ToString(IFormatProvider) |
Converte o valor numérico do objeto atual Byte para a sua representação equivalente em cadeia usando a informação de formatação específica para cultura. |
| ToString(String, IFormatProvider) |
Converte o valor do objeto atual Byte para a sua representação equivalente de cadeias usando o formato especificado e a informação de formatação específica da cultura. |
| ToString(String) |
Converte o valor do objeto atual Byte para a sua representação equivalente de cadeias usando o formato especificado. |
| TrailingZeroCount(Byte) |
Calcula o número de zeros finais num valor. |
| TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
Tenta formatar o valor da instância atual como UTF-8 no intervalo fornecido de bytes. |
| TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
Tenta formatar o valor da instância inteira não assinada de 8 bits atual no intervalo de caracteres fornecido. |
| TryParse(ReadOnlySpan<Byte>, Byte) |
Tenta converter um intervalo de caracteres UTF-8 contendo a representação da cadeia de um número para o seu equivalente inteiro sem sinal de 8 bits. |
| TryParse(ReadOnlySpan<Byte>, IFormatProvider, Byte) |
Tenta separar um intervalo de caracteres UTF-8 num valor. |
| TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, Byte) |
Tenta separar um intervalo de caracteres UTF-8 num valor. |
| TryParse(ReadOnlySpan<Char>, Byte) |
Tenta converter a representação span de um número para o seu Byte equivalente e retorna um valor que indica se a conversão teve sucesso. |
| TryParse(ReadOnlySpan<Char>, IFormatProvider, Byte) |
Tenta separar um intervalo de caracteres num valor. |
| TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, Byte) |
Converte a representação span de um número num estilo especificado e formato específico de cultura para o seu Byte equivalente. Um valor de retorno indica se a conversão teve sucesso ou falhou. |
| TryParse(String, Byte) |
Tenta converter a representação da cadeia de um número para o seu Byte equivalente e devolve um valor que indica se a conversão foi bem-sucedida. |
| TryParse(String, IFormatProvider, Byte) |
Tenta analisar uma cadeia num valor. |
| TryParse(String, NumberStyles, IFormatProvider, Byte) |
Converte a representação em cadeia de um número num estilo especificado e formato específico de cultura para o seu Byte equivalente. Um valor de retorno indica se a conversão teve sucesso ou falhou. |
Implementações de Interface Explícita
| Name | Descrição |
|---|---|
| IAdditionOperators<Byte,Byte,Byte>.Addition(Byte, Byte) |
Soma dois valores para calcular a sua soma. |
| IAdditionOperators<Byte,Byte,Byte>.CheckedAddition(Byte, Byte) |
Soma dois valores para calcular a sua soma. |
| IAdditiveIdentity<Byte,Byte>.AdditiveIdentity |
Obtém a identidade aditiva do tipo atual. |
| IBinaryInteger<Byte>.GetByteCount() |
Obtém o número de bytes que serão escritos como parte de TryWriteLittleEndian(Span<Byte>, Int32). |
| IBinaryInteger<Byte>.GetShortestBitLength() |
Obtém o comprimento, em bits, da representação do complemento dos dois mais curtos do valor atual. |
| IBinaryInteger<Byte>.TryReadBigEndian(ReadOnlySpan<Byte>, Boolean, Byte) |
Representa um inteiro sem sinal de 8 bits. |
| IBinaryInteger<Byte>.TryReadLittleEndian(ReadOnlySpan<Byte>, Boolean, Byte) |
Representa um inteiro sem sinal de 8 bits. |
| IBinaryInteger<Byte>.TryWriteBigEndian(Span<Byte>, Int32) |
Tenta escrever o valor atual, em formato big-endian, para um determinado intervalo. |
| IBinaryInteger<Byte>.TryWriteLittleEndian(Span<Byte>, Int32) |
Tenta escrever o valor atual, em formato little-endian, num determinado intervalo. |
| IBinaryNumber<Byte>.AllBitsSet |
Obtém uma instância do tipo binário em que todos os bits estão definidos. |
| IBitwiseOperators<Byte,Byte,Byte>.BitwiseAnd(Byte, Byte) |
Calcula o bit a bit de dois valores. |
| IBitwiseOperators<Byte,Byte,Byte>.BitwiseOr(Byte, Byte) |
Calcula o bit-or-ou de dois valores. |
| IBitwiseOperators<Byte,Byte,Byte>.ExclusiveOr(Byte, Byte) |
Calcula o ou exclusivo de dois valores. |
| IBitwiseOperators<Byte,Byte,Byte>.OnesComplement(Byte) |
Calcula a representação de um complemento de um dado valor. |
| IComparable.CompareTo(Object) |
Compara a instância atual com outro objeto do mesmo tipo e devolve um inteiro que indica se a instância atual precede, segue ou ocorre na mesma posição na ordem de ordenação que o outro objeto. |
| IComparisonOperators<Byte,Byte,Boolean>.GreaterThan(Byte, Byte) |
Compara dois valores para determinar qual é maior. |
| IComparisonOperators<Byte,Byte,Boolean>.GreaterThanOrEqual(Byte, Byte) |
Compara dois valores para determinar qual é maior ou igual. |
| IComparisonOperators<Byte,Byte,Boolean>.LessThan(Byte, Byte) |
Compara dois valores para determinar qual é menor. |
| IComparisonOperators<Byte,Byte,Boolean>.LessThanOrEqual(Byte, Byte) |
Compara dois valores para determinar qual é menor ou igual. |
| IConvertible.GetTypeCode() |
Devolve o TypeCode para este caso. |
| IConvertible.ToBoolean(IFormatProvider) |
Para uma descrição deste elemento, veja ToBoolean(IFormatProvider). |
| IConvertible.ToByte(IFormatProvider) |
Para uma descrição deste elemento, veja ToByte(IFormatProvider). |
| IConvertible.ToChar(IFormatProvider) |
Para uma descrição deste elemento, veja ToChar(IFormatProvider). |
| IConvertible.ToDateTime(IFormatProvider) |
Esta conversão não é suportada. Tentar usar este método lança um InvalidCastException. |
| IConvertible.ToDecimal(IFormatProvider) |
Para uma descrição deste elemento, veja ToDecimal(IFormatProvider). |
| IConvertible.ToDouble(IFormatProvider) |
Para uma descrição deste elemento, veja ToDouble(IFormatProvider). |
| IConvertible.ToInt16(IFormatProvider) |
Para uma descrição deste elemento, veja ToInt16(IFormatProvider). |
| IConvertible.ToInt32(IFormatProvider) |
Para uma descrição deste elemento, veja ToInt32(IFormatProvider). |
| IConvertible.ToInt64(IFormatProvider) |
Para uma descrição deste elemento, veja ToInt64(IFormatProvider). |
| IConvertible.ToSByte(IFormatProvider) |
Para uma descrição deste elemento, veja ToSByte(IFormatProvider). |
| IConvertible.ToSingle(IFormatProvider) |
Para uma descrição deste elemento, veja ToSingle(IFormatProvider). |
| IConvertible.ToType(Type, IFormatProvider) |
Para uma descrição deste elemento, veja ToType(Type, IFormatProvider). |
| IConvertible.ToUInt16(IFormatProvider) |
Para uma descrição deste elemento, veja ToUInt16(IFormatProvider). |
| IConvertible.ToUInt32(IFormatProvider) |
Para uma descrição deste elemento, veja ToUInt32(IFormatProvider). |
| IConvertible.ToUInt64(IFormatProvider) |
Para uma descrição deste elemento, veja ToUInt64(IFormatProvider). |
| IDecrementOperators<Byte>.CheckedDecrement(Byte) |
Diminui um valor. |
| IDecrementOperators<Byte>.Decrement(Byte) |
Diminui um valor. |
| IDivisionOperators<Byte,Byte,Byte>.Division(Byte, Byte) |
Divide um valor por outro para calcular o seu quociente. |
| IEqualityOperators<Byte,Byte,Boolean>.Equality(Byte, Byte) |
Compara dois valores para determinar a igualdade. |
| IEqualityOperators<Byte,Byte,Boolean>.Inequality(Byte, Byte) |
Compara dois valores para determinar a desigualdade. |
| IIncrementOperators<Byte>.CheckedIncrement(Byte) |
Incrementa um valor. |
| IIncrementOperators<Byte>.Increment(Byte) |
Incrementa um valor. |
| IMinMaxValue<Byte>.MaxValue |
Obtém o valor máximo do tipo atual. |
| IMinMaxValue<Byte>.MinValue |
Obtém o valor mínimo do tipo atual. |
| IModulusOperators<Byte,Byte,Byte>.Modulus(Byte, Byte) |
Divide dois valores para calcular o seu módulo ou resto. |
| IMultiplicativeIdentity<Byte,Byte>.MultiplicativeIdentity |
Obtém a identidade multiplicativa do tipo atual. |
| IMultiplyOperators<Byte,Byte,Byte>.CheckedMultiply(Byte, Byte) |
Multiplica dois valores juntos para calcular o seu produto. |
| IMultiplyOperators<Byte,Byte,Byte>.Multiply(Byte, Byte) |
Multiplica dois valores juntos para calcular o seu produto. |
| INumber<Byte>.CopySign(Byte, Byte) |
Copia o sinal de um valor para o sinal de outro valor. |
| INumber<Byte>.MaxNumber(Byte, Byte) |
Compara dois valores para calcular qual é maior e devolve o outro valor se uma entrada for |
| INumber<Byte>.MinNumber(Byte, Byte) |
Compara dois valores para calcular qual é menor e devolve o outro valor se uma entrada for |
| INumberBase<Byte>.Abs(Byte) |
Calcula o absoluto de um valor. |
| INumberBase<Byte>.IsCanonical(Byte) |
Determina se um valor está na sua representação canónica. |
| INumberBase<Byte>.IsComplexNumber(Byte) |
Determina se um valor representa um número complexo. |
| INumberBase<Byte>.IsFinite(Byte) |
Determina se um valor é finito. |
| INumberBase<Byte>.IsImaginaryNumber(Byte) |
Determina se um valor representa um número puramente imaginário. |
| INumberBase<Byte>.IsInfinity(Byte) |
Determina se um valor é infinito. |
| INumberBase<Byte>.IsInteger(Byte) |
Determina se um valor representa um número inteiro. |
| INumberBase<Byte>.IsNaN(Byte) |
Determina se um valor é NaN. |
| INumberBase<Byte>.IsNegative(Byte) |
Determina se um valor é negativo. |
| INumberBase<Byte>.IsNegativeInfinity(Byte) |
Determina se um valor é menos infinito. |
| INumberBase<Byte>.IsNormal(Byte) |
Determina se um valor é normal. |
| INumberBase<Byte>.IsPositive(Byte) |
Determina se um valor é positivo. |
| INumberBase<Byte>.IsPositiveInfinity(Byte) |
Determina se um valor é infinito positivo. |
| INumberBase<Byte>.IsRealNumber(Byte) |
Determina se um valor representa um número real. |
| INumberBase<Byte>.IsSubnormal(Byte) |
Determina se um valor é subnormal. |
| INumberBase<Byte>.IsZero(Byte) |
Determina se um valor é zero. |
| INumberBase<Byte>.MaxMagnitude(Byte, Byte) |
Compara dois valores para calcular qual é maior. |
| INumberBase<Byte>.MaxMagnitudeNumber(Byte, Byte) |
Compara dois valores para calcular qual tem maior magnitude e devolve o outro valor se uma entrada for |
| INumberBase<Byte>.MinMagnitude(Byte, Byte) |
Compara dois valores para calcular qual é menor. |
| INumberBase<Byte>.MinMagnitudeNumber(Byte, Byte) |
Compara dois valores para calcular que tem a magnitude menor e devolve o outro valor se uma entrada for |
| INumberBase<Byte>.MultiplyAddEstimate(Byte, Byte, Byte) |
Calcula uma estimativa de ( |
| INumberBase<Byte>.One |
Obtém o valor |
| INumberBase<Byte>.Radix |
Obtém a raiz, ou base, para o tipo. |
| INumberBase<Byte>.TryConvertFromChecked<TOther>(TOther, Byte) |
Representa um inteiro sem sinal de 8 bits. |
| INumberBase<Byte>.TryConvertFromSaturating<TOther>(TOther, Byte) |
Representa um inteiro sem sinal de 8 bits. |
| INumberBase<Byte>.TryConvertFromTruncating<TOther>(TOther, Byte) |
Representa um inteiro sem sinal de 8 bits. |
| INumberBase<Byte>.TryConvertToChecked<TOther>(Byte, TOther) |
Tenta converter uma instância do tipo atual para outro tipo, lançando uma exceção de overflow para quaisquer valores que estejam fora do intervalo representável do tipo atual. |
| INumberBase<Byte>.TryConvertToSaturating<TOther>(Byte, TOther) |
Tenta converter uma instância do tipo atual para outro tipo, saturando quaisquer valores que estejam fora do intervalo representável do tipo atual. |
| INumberBase<Byte>.TryConvertToTruncating<TOther>(Byte, TOther) |
Tenta converter uma instância do tipo atual para outro tipo, truncando quaisquer valores que estejam fora do intervalo representável do tipo atual. |
| INumberBase<Byte>.Zero |
Obtém o valor |
| IShiftOperators<Byte,Int32,Byte>.LeftShift(Byte, Int32) |
Desloca um valor deixado por uma determinada quantia. |
| IShiftOperators<Byte,Int32,Byte>.RightShift(Byte, Int32) |
Desloca um valor para a direita numa determinada quantia. |
| IShiftOperators<Byte,Int32,Byte>.UnsignedRightShift(Byte, Int32) |
Desloca um valor para a direita numa determinada quantia. |
| ISubtractionOperators<Byte,Byte,Byte>.CheckedSubtraction(Byte, Byte) |
Subtrai dois valores para calcular a sua diferença. |
| ISubtractionOperators<Byte,Byte,Byte>.Subtraction(Byte, Byte) |
Subtrai dois valores para calcular a sua diferença. |
| IUnaryNegationOperators<Byte,Byte>.CheckedUnaryNegation(Byte) |
Calcula a negação unária verificada de um valor. |
| IUnaryNegationOperators<Byte,Byte>.UnaryNegation(Byte) |
Calcula a negação unária de um valor. |
| IUnaryPlusOperators<Byte,Byte>.UnaryPlus(Byte) |
Calcula o plus unário de um valor. |
Aplica-se a
Segurança de Thread
Todos os membros deste tipo são seguros para fios. Os membros que parecem modificar o estado da instância retornam na verdade uma nova instância inicializada com o novo valor. Como em qualquer outro tipo, a leitura e escrita numa variável partilhada que contenha uma instância deste tipo deve ser protegida por um bloqueio para garantir a segurança do thread.