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<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<System::Byte>, IConvertible, IEquatable<System::Byte>, IParsable<System::Byte>, ISpanParsable<System::Byte>, IUtf8SpanFormattable, 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, 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, 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>
public readonly struct Byte : IComparable<byte>, IConvertible, IEquatable<byte>, IParsable<byte>, ISpanParsable<byte>, IUtf8SpanFormattable, 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>
[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
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 IUtf8SpanParsable<byte>
interface IShiftOperators<byte, int, byte>
interface IMinMaxValue<byte>
interface IUnsignedNumber<byte>
interface IUtf8SpanFormattable
[<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 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 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), IUtf8SpanFormattable, IUtf8SpanParsable(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 ISpanFormattable IComparable<TSelf> IEquatable<TSelf> IParsable<Byte> IParsable<TSelf> ISpanParsable<Byte> ISpanParsable<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> IUtf8SpanFormattable IUtf8SpanParsable<Byte> IUtf8SpanParsable<TSelf>
Comentários
Byte é um tipo de valor imutável que representa inteiros sem sinal com valores que variam de 0 (que é representado pela Byte.MinValue constante) a 255 (que é representado pela Byte.MaxValue constante). O .NET também inclui um tipo de valor inteiro de 8 bits assinado, SByte, que representa valores que variam de -128 a 127.
Criando uma instância de um valor de byte
Você pode criar uma instância de um Byte valor de várias maneiras:
Você pode declarar uma Byte variável e atribuir a ela um valor inteiro literal que está dentro do intervalo do Byte tipo de dados. O exemplo a seguir declara duas Byte variáveis e atribui-lhes 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 no Visual Basic, se
Option Strict
estiver ativado. Se o valor não byte for um Singlevalor , 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("{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 Byte valor. Isso é possível porque Byte dá suporte à IConvertible interface . 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 TryParse para converter a representação de cadeia de caracteres de um Byte valor 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 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 Byte tipo também dá suporte aos operadores bit a bit AND
, OR
, XOR
, shift esquerdo e deslocamento para a direita.
Você pode usar os operadores numéricos padrão para comparar dois Byte valores ou pode chamar o CompareTo método ou 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 caracteres de formato numérico padrão e cadeias de caracteres de formato numérico personalizado.) No entanto, normalmente, os valores de bytes 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 formata os elementos em uma matriz de Byte valores destas 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 Byte valor como uma cadeia de caracteres binária, octal, decimal ou hexadecimal chamando o ToString(Byte, Int32) método 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 hexadecimal de uma matriz de valores de bytes.
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, convém 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 BitConverter.GetBytes método podem converter cada um dos tipos de dados primitivos em uma matriz de bytes e o BigInteger.ToByteArray método converte um BigInteger valor em uma matriz de bytes.
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 Byte valores 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 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 Byte valor 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("{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 não assinados e assinados, as operações bit a bit são complicadas pelo fato de que os SByte valores usam representação de sinal e magnitude para valores positivos e a representação complementar 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 sem sinal 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
Clamp(Byte, Byte, Byte) |
Fixa um valor a um valor mínimo e máximo inclusivo. |
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. |
CreateChecked<TOther>(TOther) |
Cria uma instância do tipo atual de um valor, gerando uma exceção de estouro para quaisquer valores que estejam fora do intervalo representável do tipo atual. |
CreateSaturating<TOther>(TOther) |
Cria uma instância do tipo atual de um valor, saturando todos os valores que estão fora do intervalo representável do tipo atual. |
CreateTruncating<TOther>(TOther) |
Cria uma instância do tipo atual de um valor, truncando todos os valores que estão fora do intervalo representável do tipo atual. |
DivRem(Byte, Byte) |
Calcula o quociente e o restante de dois valores. |
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() | |
IsEvenInteger(Byte) |
Determina se um valor representa um número integral par. |
IsOddInteger(Byte) |
Determina se um valor representa um número integral ímpar. |
IsPow2(Byte) |
Determina se um valor é uma potência de dois. |
LeadingZeroCount(Byte) |
Calcula o número de zeros à esquerda em um valor. |
Log2(Byte) |
Calcula o log2 de um valor. |
Max(Byte, Byte) |
Compara dois valores com a computação, que é maior. |
Min(Byte, Byte) |
Compara dois valores com a computação que é menor. |
Parse(ReadOnlySpan<Byte>, IFormatProvider) |
Analisa um intervalo de caracteres UTF-8 em um valor. |
Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider) |
Analisa um intervalo de caracteres UTF-8 em um valor. |
Parse(ReadOnlySpan<Char>, IFormatProvider) |
Analisa um intervalo de caracteres em um valor. |
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. |
PopCount(Byte) |
Calcula o número de bits definidos em um valor. |
RotateLeft(Byte, Int32) |
Gira um valor deixado por um determinado valor. |
RotateRight(Byte, Int32) |
Gira um valor para a direita em um determinado valor. |
Sign(Byte) |
Calcula o sinal de um valor. |
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. |
TrailingZeroCount(Byte) |
Calcula o número de zeros à direita em um valor. |
TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider) |
Tenta formatar o valor da instância atual como UTF-8 no intervalo de bytes fornecido. |
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<Byte>, Byte) |
Tenta converter um intervalo de caracteres UTF-8 que contém a representação de cadeia de caracteres de um número em seu inteiro sem sinal de 8 bits equivalente. |
TryParse(ReadOnlySpan<Byte>, IFormatProvider, Byte) |
Tenta analisar um intervalo de caracteres UTF-8 em um valor. |
TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, Byte) |
Tenta analisar um intervalo de caracteres UTF-8 em um valor. |
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>, IFormatProvider, Byte) |
Tenta analisar um intervalo de caracteres em um valor. |
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, IFormatProvider, Byte) |
Tenta analisar uma cadeia de caracteres em um valor. |
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
IAdditionOperators<Byte,Byte,Byte>.Addition(Byte, Byte) |
Adiciona dois valores juntos para calcular sua soma. |
IAdditionOperators<Byte,Byte,Byte>.CheckedAddition(Byte, Byte) |
Adiciona dois valores juntos para calcular 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 gravados como parte de TryWriteLittleEndian(Span<Byte>, Int32). |
IBinaryInteger<Byte>.GetShortestBitLength() |
Obtém o comprimento, em bits, da representação complementar 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 gravar o valor atual, no formato big-endian, em um determinado intervalo. |
IBinaryInteger<Byte>.TryWriteLittleEndian(Span<Byte>, Int32) |
Tenta gravar o valor atual, no formato little-endian, em um determinado intervalo. |
IBinaryNumber<Byte>.AllBitsSet |
Obtém uma instância do tipo binário no qual todos os bits são definidos. |
IBitwiseOperators<Byte,Byte,Byte>.BitwiseAnd(Byte, Byte) |
Calcula o bit a bit e de dois valores. |
IBitwiseOperators<Byte,Byte,Byte>.BitwiseOr(Byte, Byte) |
Calcula o bit a bit ou dois valores. |
IBitwiseOperators<Byte,Byte,Byte>.ExclusiveOr(Byte, Byte) |
Calcula o exclusivo ou de dois valores. |
IBitwiseOperators<Byte,Byte,Byte>.OnesComplement(Byte) |
Calcula a representação ones-complement de um determinado valor. |
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. |
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() |
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). |
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 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 juntos para calcular 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 seu produto. |
IMultiplyOperators<Byte,Byte,Byte>.Multiply(Byte, Byte) |
Multiplica dois valores juntos para calcular 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 com a computação, que é maior e retorna o outro valor se uma entrada for |
INumber<Byte>.MinNumber(Byte, Byte) |
Compara dois valores com a computação, que é menor e retorna 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á em 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 imaginário puro. |
INumberBase<Byte>.IsInfinity(Byte) |
Determina se um valor é infinito. |
INumberBase<Byte>.IsInteger(Byte) |
Determina se um valor representa um número integral. |
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 é infinito negativo. |
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 com a computação, que é maior. |
INumberBase<Byte>.MaxMagnitudeNumber(Byte, Byte) |
Compara dois valores com a computação que tem a magnitude maior e retorna o outro valor se uma entrada for |
INumberBase<Byte>.MinMagnitude(Byte, Byte) |
Compara dois valores com a computação que é menor. |
INumberBase<Byte>.MinMagnitudeNumber(Byte, Byte) |
Compara dois valores com a computação que tem a magnitude menor e retorna o outro valor se uma entrada é |
INumberBase<Byte>.One |
Obtém o valor |
INumberBase<Byte>.Radix |
Obtém a 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 em outro tipo, gerando uma exceção de estouro 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 em outro tipo, saturando todos os valores que estão fora do intervalo representável do tipo atual. |
INumberBase<Byte>.TryConvertToTruncating<TOther>(Byte, TOther) |
Tenta converter uma instância do tipo atual em 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 para a esquerda por um determinado valor. |
IShiftOperators<Byte,Int32,Byte>.RightShift(Byte, Int32) |
Desloca um valor para a direita em um determinado valor. |
IShiftOperators<Byte,Int32,Byte>.UnsignedRightShift(Byte, Int32) |
Desloca um valor para a direita em um determinado valor. |
ISubtractionOperators<Byte,Byte,Byte>.CheckedSubtraction(Byte, Byte) |
Subtrai dois valores para calcular sua diferença. |
ISubtractionOperators<Byte,Byte,Byte>.Subtraction(Byte, Byte) |
Subtrai dois valores para calcular 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 a mais unária de um valor. |
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.