Byte Struct

Definizione

Rappresenta un intero senza segno a 8 bit.

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
Ereditarietà
Attributi
Implementazioni
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>

Commenti

Byte è un tipo valore non modificabile che rappresenta numeri interi senza segno con valori compresi tra 0 (rappresentato dalla Byte.MinValue costante) e 255 (rappresentato dalla Byte.MaxValue costante). .NET include anche un tipo di valore intero a 8 bit con segno, SByte, che rappresenta i valori compresi tra -128 e 127.

Definire un valore byte

È possibile istanziare un valore Byte in diversi modi:

  • È possibile dichiarare una Byte variabile e assegnargli un valore intero letterale compreso nell'intervallo del Byte tipo di dati. L'esempio seguente dichiara due variabili Byte e assegna loro dei valori in questo modo.

    byte value1 = 64;
    byte value2 = 255;
    
    let value1 = 64uy
    let value2 = 255uy
    
    Dim value1 As Byte = 64
    Dim value2 As Byte = 255
    
  • È possibile assegnare un valore numerico non byte a un byte. Si tratta di una conversione di tipo narrowing, quindi richiede un operatore cast in C# e F#, oppure un metodo di conversione in Visual Basic se Option Strict è attivo. Se il valore non byte è un valore Single, Double o Decimal che include un componente frazionario, la gestione della sua parte frazionaria dipende dal compilatore che effettua la conversione. Nell'esempio seguente vengono assegnati diversi valori numerici alle Byte variabili.

    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
    //       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
    
  • È possibile chiamare un metodo della Convert classe per convertire qualsiasi tipo supportato in un Byte valore. Ciò è possibile perché Byte supporta l'interfaccia IConvertible . Nell'esempio seguente viene illustrata la conversione di una matrice di Int32 valori in Byte valori.

    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.
    
  • È possibile chiamare il metodo Parse o TryParse per convertire la rappresentazione di stringa di un valore Byte in un Byte. La stringa può contenere cifre decimali o esadecimali. Nell'esempio seguente viene illustrata l'operazione di analisi usando sia una stringa decimale che una stringa esadecimale.

    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
    //       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
    

Eseguire operazioni sui valori byte

Il Byte tipo supporta operazioni matematiche standard, ad esempio addizione, sottrazione, divisione, moltiplicazione, sottrazione, negazione e negazione unaria. Analogamente agli altri tipi integrali, il tipo Byte supporta anche gli operatori bitwise AND, OR, XOR, spostamento a sinistra e spostamento a destra.

È possibile usare gli operatori numerici standard per confrontare due Byte valori oppure chiamare il CompareTo metodo o Equals .

È anche possibile chiamare i membri della Math classe per eseguire un'ampia gamma di operazioni numeriche, tra cui ottenere il valore assoluto di un numero, calcolare il quoziente e il resto dalla divisione integrale, determinare il valore massimo o minimo di due interi, ottenere il segno di un numero e arrotondare un numero.

Rappresentare un byte come stringa

Il Byte tipo fornisce il supporto completo per le stringhe di formato numerico standard e personalizzato. Per altre informazioni, vedere Formattazione di tipi, stringhe di formato numerico standard e stringhe di formato numerico personalizzato. Tuttavia, più comunemente, i valori di byte sono rappresentati come valori di una cifra a tre cifre senza formattazione aggiuntiva o come valori esadecimali a due cifre.

Per formattare un Byte valore come stringa integrale senza zeri iniziali, è possibile chiamare il metodo senza ToString() parametri. Usando l'identificatore di formato "D", è anche possibile includere un numero specificato di zeri iniziali nella rappresentazione di stringa. Usando l'identificatore di formato "X", è possibile rappresentare un Byte valore come stringa esadecimale. L'esempio seguente formatta gli elementi in una matrice di Byte valori in questi tre modi.

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

È anche possibile formattare un Byte valore come stringa binaria, ottale, decimale o esadecimale chiamando il ToString(Byte, Int32) metodo e specificando la base come secondo parametro del metodo. Nell'esempio seguente viene chiamato questo metodo per visualizzare le rappresentazioni binarie, ottali ed esadecimali di una matrice di valori di 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

Lavorare con valori Byte non decimali

Oltre a usare singoli byte come valori decimali, è possibile eseguire operazioni bit per bit con valori di byte oppure usare matrici di byte o con le rappresentazioni binarie o esadecimali dei valori di byte. Ad esempio, gli overload del BitConverter.GetBytes metodo possono convertire ognuno dei tipi di dati primitivi in una matrice di byte e il BigInteger.ToByteArray metodo converte un BigInteger valore in una matrice di byte.

Byte i valori sono rappresentati in 8 bit in base alla loro grandezza, senza segno di bit. Questo aspetto è importante da tenere presente quando si eseguono operazioni bit per bit sui Byte valori o quando si lavora con singoli bit. Per eseguire un'operazione numerica, booleana o di confronto su due valori non decimali, entrambi i valori devono usare la stessa rappresentazione.

Quando un'operazione viene eseguita su due Byte valori, i valori condividono la stessa rappresentazione, in modo che il risultato sia accurato. Questo è illustrato nell'esempio seguente, che maschera il bit più basso di un Byte valore per assicurarsi che sia pari.

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

D'altra parte, quando si lavora con bit senza segno e con segno, le operazioni bit per bit sono complicate dal fatto che i SByte valori usano la rappresentazione di segno e grandezza per i valori positivi e la rappresentazione di complemento di due per i valori negativi. Per eseguire un'operazione bit per bit significativa, i valori devono essere convertiti in due rappresentazioni equivalenti e le informazioni sul bit del segno devono essere mantenute. L'esempio seguente esegue questa operazione per mascherare i bit 2 e 4 in una matrice composta da numeri con segno e numeri senza segno a 8 bit.

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)

Campi

Nome Descrizione
MaxValue

Rappresenta il valore massimo possibile di un oggetto Byte. Questo campo è costante.

MinValue

Rappresenta il valore più piccolo possibile di un oggetto Byte. Questo campo è costante.

Metodi

Nome Descrizione
Clamp(Byte, Byte, Byte)

Blocca un valore a un valore minimo e massimo inclusivo.

CompareTo(Byte)

Confronta questa istanza con un intero senza segno a 8 bit specificato e restituisce un'indicazione dei relativi valori.

CompareTo(Object)

Confronta questa istanza con un oggetto specificato e restituisce un'indicazione dei relativi valori.

CreateChecked<TOther>(TOther)

Crea un'istanza del tipo corrente da un valore, generando un'eccezione di overflow per tutti i valori che non rientrano nell'intervallo rappresentabile del tipo corrente.

CreateSaturating<TOther>(TOther)

Crea un'istanza del tipo corrente da un valore, saturando tutti i valori che non rientrano nell'intervallo rappresentabile del tipo corrente.

CreateTruncating<TOther>(TOther)

Crea un'istanza del tipo corrente da un valore, troncando tutti i valori che non rientrano nell'intervallo rappresentabile del tipo corrente.

DivRem(Byte, Byte)

Calcola il quoziente e il resto di due valori.

Equals(Byte)

Restituisce un valore che indica se questa istanza e un oggetto specificato Byte rappresentano lo stesso valore.

Equals(Object)

Restituisce un valore che indica se questa istanza è uguale a un oggetto specificato.

GetHashCode()

Restituisce il codice hash per questa istanza.

GetTypeCode()

Restituisce l'oggetto per il TypeCode tipo di Bytevalore .

IsEvenInteger(Byte)

Determina se un valore rappresenta un numero integrale pari.

IsOddInteger(Byte)

Determina se un valore rappresenta un numero integrale dispari.

IsPow2(Byte)

Determina se un valore è una potenza di due.

LeadingZeroCount(Byte)

Calcola il numero di zeri iniziali in un valore.

Log10(Byte)

Rappresenta un intero senza segno a 8 bit.

Log2(Byte)

Calcola il log2 di un valore.

Max(Byte, Byte)

Confronta due valori con il calcolo maggiore.

Min(Byte, Byte)

Confronta due valori con il calcolo minore.

Parse(ReadOnlySpan<Byte>, IFormatProvider)

Analizza un intervallo di caratteri UTF-8 in un valore.

Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider)

Analizza un intervallo di caratteri UTF-8 in un valore.

Parse(ReadOnlySpan<Char>, IFormatProvider)

Analizza un intervallo di caratteri in un valore.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

Converte la rappresentazione dell'intervallo di un numero in uno stile e un formato specifico delle impostazioni cultura specificati nell'equivalente Byte .

Parse(String, IFormatProvider)

Converte la rappresentazione di stringa di un numero in un formato specifico delle impostazioni cultura specificato nell'equivalente Byte .

Parse(String, NumberStyles, IFormatProvider)

Converte la rappresentazione di stringa di un numero in uno stile e un formato specifico delle impostazioni cultura specificati nell'equivalente Byte .

Parse(String, NumberStyles)

Converte la rappresentazione di stringa di un numero in uno stile specificato nell'equivalente Byte .

Parse(String)

Converte la rappresentazione di stringa di un numero nell'equivalente Byte .

PopCount(Byte)

Calcola il numero di bit impostati in un valore.

RotateLeft(Byte, Int32)

Ruota un valore a sinistra di una determinata quantità.

RotateRight(Byte, Int32)

Ruota un valore a destra di una determinata quantità.

Sign(Byte)

Calcola il segno di un valore.

ToString()

Converte il valore dell'oggetto corrente Byte nella rappresentazione di stringa equivalente.

ToString(IFormatProvider)

Converte il valore numerico dell'oggetto corrente Byte nella rappresentazione di stringa equivalente utilizzando le informazioni di formattazione specifiche delle impostazioni cultura specificate.

ToString(String, IFormatProvider)

Converte il valore dell'oggetto corrente Byte nella rappresentazione di stringa equivalente utilizzando il formato specificato e le informazioni di formattazione specifiche delle impostazioni cultura.

ToString(String)

Converte il valore dell'oggetto corrente Byte nella rappresentazione di stringa equivalente utilizzando il formato specificato.

TrailingZeroCount(Byte)

Calcola il numero di zeri finali in un valore.

TryFormat(Span<Byte>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Prova a formattare il valore dell'istanza corrente come UTF-8 nell'intervallo di byte specificato.

TryFormat(Span<Char>, Int32, ReadOnlySpan<Char>, IFormatProvider)

Prova a formattare il valore dell'istanza intero senza segno a 8 bit corrente nell'intervallo di caratteri specificato.

TryParse(ReadOnlySpan<Byte>, Byte)

Tenta di convertire un intervallo di caratteri UTF-8 contenente la rappresentazione di stringa di un numero nell'equivalente intero senza segno a 8 bit.

TryParse(ReadOnlySpan<Byte>, IFormatProvider, Byte)

Prova ad analizzare un intervallo di caratteri UTF-8 in un valore.

TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, Byte)

Prova ad analizzare un intervallo di caratteri UTF-8 in un valore.

TryParse(ReadOnlySpan<Char>, Byte)

Tenta di convertire la rappresentazione di intervallo di un numero nell'equivalente Byte e restituisce un valore che indica se la conversione ha avuto esito positivo.

TryParse(ReadOnlySpan<Char>, IFormatProvider, Byte)

Tenta di analizzare un intervallo di caratteri in un valore.

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, Byte)

Converte la rappresentazione dell'intervallo di un numero in uno stile e un formato specifico delle impostazioni cultura specificati nell'equivalente Byte . Un valore restituito indica se la conversione ha avuto esito positivo o negativo.

TryParse(String, Byte)

Tenta di convertire la rappresentazione di stringa di un numero nell'equivalente Byte e restituisce un valore che indica se la conversione ha avuto esito positivo.

TryParse(String, IFormatProvider, Byte)

Tenta di analizzare una stringa in un valore.

TryParse(String, NumberStyles, IFormatProvider, Byte)

Converte la rappresentazione di stringa di un numero in uno stile e un formato specifico delle impostazioni cultura specificati nell'equivalente Byte . Un valore restituito indica se la conversione ha avuto esito positivo o negativo.

Implementazioni dell'interfaccia esplicita

Nome Descrizione
IAdditionOperators<Byte,Byte,Byte>.Addition(Byte, Byte)

Aggiunge due valori insieme per calcolare la somma.

IAdditionOperators<Byte,Byte,Byte>.CheckedAddition(Byte, Byte)

Aggiunge due valori insieme per calcolare la somma.

IAdditiveIdentity<Byte,Byte>.AdditiveIdentity

Ottiene l'identità aggiuntiva del tipo corrente.

IBinaryInteger<Byte>.GetByteCount()

Ottiene il numero di byte che verranno scritti come parte di TryWriteLittleEndian(Span<Byte>, Int32).

IBinaryInteger<Byte>.GetShortestBitLength()

Ottiene la lunghezza, espressa in bit, della rappresentazione complementare più breve del valore corrente.

IBinaryInteger<Byte>.TryReadBigEndian(ReadOnlySpan<Byte>, Boolean, Byte)

Rappresenta un intero senza segno a 8 bit.

IBinaryInteger<Byte>.TryReadLittleEndian(ReadOnlySpan<Byte>, Boolean, Byte)

Rappresenta un intero senza segno a 8 bit.

IBinaryInteger<Byte>.TryWriteBigEndian(Span<Byte>, Int32)

Prova a scrivere il valore corrente, in formato big-endian, in un intervallo specificato.

IBinaryInteger<Byte>.TryWriteLittleEndian(Span<Byte>, Int32)

Prova a scrivere il valore corrente, in formato little-endian, in un intervallo specificato.

IBinaryNumber<Byte>.AllBitsSet

Ottiene un'istanza del tipo binario in cui vengono impostati tutti i bit.

IBitwiseOperators<Byte,Byte,Byte>.BitwiseAnd(Byte, Byte)

Calcola i valori bit per bit e di due valori.

IBitwiseOperators<Byte,Byte,Byte>.BitwiseOr(Byte, Byte)

Calcola i valori bit per bit o di due valori.

IBitwiseOperators<Byte,Byte,Byte>.ExclusiveOr(Byte, Byte)

Calcola il valore esclusivo o di due valori.

IBitwiseOperators<Byte,Byte,Byte>.OnesComplement(Byte)

Calcola la rappresentazione di complemento di un determinato valore.

IComparable.CompareTo(Object)

Confronta l'istanza corrente con un altro oggetto dello stesso tipo e restituisce un numero intero che indica se l'istanza corrente precede, segue o si trova nella stessa posizione nell'ordinamento dell'altro oggetto.

IComparisonOperators<Byte,Byte,Boolean>.GreaterThan(Byte, Byte)

Confronta due valori per determinare quale è maggiore.

IComparisonOperators<Byte,Byte,Boolean>.GreaterThanOrEqual(Byte, Byte)

Confronta due valori per determinare quale è maggiore o uguale.

IComparisonOperators<Byte,Byte,Boolean>.LessThan(Byte, Byte)

Confronta due valori per determinare quale è minore.

IComparisonOperators<Byte,Byte,Boolean>.LessThanOrEqual(Byte, Byte)

Confronta due valori per determinare quale è minore o uguale.

IConvertible.GetTypeCode()

Restituisce l'oggetto TypeCode per questa istanza.

IConvertible.ToBoolean(IFormatProvider)

Per una descrizione di questo membro, vedere ToBoolean(IFormatProvider).

IConvertible.ToByte(IFormatProvider)

Per una descrizione di questo membro, vedere ToByte(IFormatProvider).

IConvertible.ToChar(IFormatProvider)

Per una descrizione di questo membro, vedere ToChar(IFormatProvider).

IConvertible.ToDateTime(IFormatProvider)

Questa conversione non è supportata. Il tentativo di utilizzare questo metodo genera un'eccezione InvalidCastException.

IConvertible.ToDecimal(IFormatProvider)

Per una descrizione di questo membro, vedere ToDecimal(IFormatProvider).

IConvertible.ToDouble(IFormatProvider)

Per una descrizione di questo membro, vedere ToDouble(IFormatProvider).

IConvertible.ToInt16(IFormatProvider)

Per una descrizione di questo membro, vedere ToInt16(IFormatProvider).

IConvertible.ToInt32(IFormatProvider)

Per una descrizione di questo membro, vedere ToInt32(IFormatProvider).

IConvertible.ToInt64(IFormatProvider)

Per una descrizione di questo membro, vedere ToInt64(IFormatProvider).

IConvertible.ToSByte(IFormatProvider)

Per una descrizione di questo membro, vedere ToSByte(IFormatProvider).

IConvertible.ToSingle(IFormatProvider)

Per una descrizione di questo membro, vedere ToSingle(IFormatProvider).

IConvertible.ToType(Type, IFormatProvider)

Per una descrizione di questo membro, vedere ToType(Type, IFormatProvider).

IConvertible.ToUInt16(IFormatProvider)

Per una descrizione di questo membro, vedere ToUInt16(IFormatProvider).

IConvertible.ToUInt32(IFormatProvider)

Per una descrizione di questo membro, vedere ToUInt32(IFormatProvider).

IConvertible.ToUInt64(IFormatProvider)

Per una descrizione di questo membro, vedere ToUInt64(IFormatProvider).

IDecrementOperators<Byte>.CheckedDecrement(Byte)

Decrementa un valore.

IDecrementOperators<Byte>.Decrement(Byte)

Decrementa un valore.

IDivisionOperators<Byte,Byte,Byte>.Division(Byte, Byte)

Divide un valore per un altro per calcolare il quoziente.

IEqualityOperators<Byte,Byte,Boolean>.Equality(Byte, Byte)

Confronta due valori per determinare l'uguaglianza.

IEqualityOperators<Byte,Byte,Boolean>.Inequality(Byte, Byte)

Confronta due valori per determinare la disuguaglianza.

IIncrementOperators<Byte>.CheckedIncrement(Byte)

Incrementa un valore.

IIncrementOperators<Byte>.Increment(Byte)

Incrementa un valore.

IMinMaxValue<Byte>.MaxValue

Ottiene il valore massimo del tipo corrente.

IMinMaxValue<Byte>.MinValue

Ottiene il valore minimo del tipo corrente.

IModulusOperators<Byte,Byte,Byte>.Modulus(Byte, Byte)

Divide due valori insieme per calcolare il modulo o il resto.

IMultiplicativeIdentity<Byte,Byte>.MultiplicativeIdentity

Ottiene l'identità moltiplicativa del tipo corrente.

IMultiplyOperators<Byte,Byte,Byte>.CheckedMultiply(Byte, Byte)

Moltiplica due valori insieme per calcolare il prodotto.

IMultiplyOperators<Byte,Byte,Byte>.Multiply(Byte, Byte)

Moltiplica due valori insieme per calcolare il prodotto.

INumber<Byte>.CopySign(Byte, Byte)

Copia il segno di un valore nel segno di un altro valore.

INumber<Byte>.MaxNumber(Byte, Byte)

Confronta due valori con il calcolo maggiore e restituendo l'altro valore se un input è NaN.

INumber<Byte>.MinNumber(Byte, Byte)

Confronta due valori con il calcolo minore e restituendo l'altro valore se un input è NaN.

INumberBase<Byte>.Abs(Byte)

Calcola l'assoluto di un valore.

INumberBase<Byte>.IsCanonical(Byte)

Determina se un valore è nella relativa rappresentazione canonica.

INumberBase<Byte>.IsComplexNumber(Byte)

Determina se un valore rappresenta un numero complesso.

INumberBase<Byte>.IsFinite(Byte)

Determina se un valore è finito.

INumberBase<Byte>.IsImaginaryNumber(Byte)

Determina se un valore rappresenta un numero immaginario puro.

INumberBase<Byte>.IsInfinity(Byte)

Determina se un valore è infinito.

INumberBase<Byte>.IsInteger(Byte)

Determina se un valore rappresenta un numero integrale.

INumberBase<Byte>.IsNaN(Byte)

Determina se un valore è NaN.

INumberBase<Byte>.IsNegative(Byte)

Determina se un valore è negativo.

INumberBase<Byte>.IsNegativeInfinity(Byte)

Determina se un valore è infinito negativo.

INumberBase<Byte>.IsNormal(Byte)

Determina se un valore è normale.

INumberBase<Byte>.IsPositive(Byte)

Determina se un valore è positivo.

INumberBase<Byte>.IsPositiveInfinity(Byte)

Determina se un valore è infinito positivo.

INumberBase<Byte>.IsRealNumber(Byte)

Determina se un valore rappresenta un numero reale.

INumberBase<Byte>.IsSubnormal(Byte)

Determina se un valore è sottonormamale.

INumberBase<Byte>.IsZero(Byte)

Determina se un valore è zero.

INumberBase<Byte>.MaxMagnitude(Byte, Byte)

Confronta due valori con il calcolo maggiore.

INumberBase<Byte>.MaxMagnitudeNumber(Byte, Byte)

Confronta due valori con il calcolo con la grandezza maggiore e restituendo l'altro valore se un input è NaN.

INumberBase<Byte>.MinMagnitude(Byte, Byte)

Confronta due valori con il calcolo minore.

INumberBase<Byte>.MinMagnitudeNumber(Byte, Byte)

Confronta due valori con il calcolo con la grandezza minore e restituendo l'altro valore se un input è NaN.

INumberBase<Byte>.MultiplyAddEstimate(Byte, Byte, Byte)

Calcola una stima di (left * right) + . addend

INumberBase<Byte>.One

Ottiene il valore 1 per il tipo.

INumberBase<Byte>.Radix

Ottiene la radice o la base del tipo.

INumberBase<Byte>.TryConvertFromChecked<TOther>(TOther, Byte)

Rappresenta un intero senza segno a 8 bit.

INumberBase<Byte>.TryConvertFromSaturating<TOther>(TOther, Byte)

Rappresenta un intero senza segno a 8 bit.

INumberBase<Byte>.TryConvertFromTruncating<TOther>(TOther, Byte)

Rappresenta un intero senza segno a 8 bit.

INumberBase<Byte>.TryConvertToChecked<TOther>(Byte, TOther)

Tenta di convertire un'istanza del tipo corrente in un altro tipo, generando un'eccezione di overflow per tutti i valori che non rientrano nell'intervallo rappresentabile del tipo corrente.

INumberBase<Byte>.TryConvertToSaturating<TOther>(Byte, TOther)

Tenta di convertire un'istanza del tipo corrente in un altro tipo, saturando tutti i valori che non rientrano nell'intervallo rappresentabile del tipo corrente.

INumberBase<Byte>.TryConvertToTruncating<TOther>(Byte, TOther)

Tenta di convertire un'istanza del tipo corrente in un altro tipo, troncando tutti i valori che non rientrano nell'intervallo rappresentabile del tipo corrente.

INumberBase<Byte>.Zero

Ottiene il valore 0 per il tipo.

IShiftOperators<Byte,Int32,Byte>.LeftShift(Byte, Int32)

Sposta un valore a sinistra di una determinata quantità.

IShiftOperators<Byte,Int32,Byte>.RightShift(Byte, Int32)

Sposta un valore a destra di una determinata quantità.

IShiftOperators<Byte,Int32,Byte>.UnsignedRightShift(Byte, Int32)

Sposta un valore a destra di una determinata quantità.

ISubtractionOperators<Byte,Byte,Byte>.CheckedSubtraction(Byte, Byte)

Sottrae due valori per calcolare la differenza.

ISubtractionOperators<Byte,Byte,Byte>.Subtraction(Byte, Byte)

Sottrae due valori per calcolare la differenza.

IUnaryNegationOperators<Byte,Byte>.CheckedUnaryNegation(Byte)

Calcola la negazione unaria controllata di un valore.

IUnaryNegationOperators<Byte,Byte>.UnaryNegation(Byte)

Calcola la negazione unaria di un valore.

IUnaryPlusOperators<Byte,Byte>.UnaryPlus(Byte)

Calcola il plus unario di un valore.

Si applica a

Thread safety

Tutti i membri di questo tipo sono thread-safe. I membri che sembrano modificare lo stato dell'istanza restituiscono effettivamente una nuova istanza inizializzata con il nuovo valore. Come per qualsiasi altro tipo, la lettura e la scrittura in una variabile condivisa contenente un'istanza di questo tipo devono essere protette da un blocco per garantire la thread safety.

Vedi anche