Byte Struktur

Definisi

Mewakili bilangan bulat yang tidak ditandatangani 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
Warisan
Atribut
Penerapan
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>

Keterangan

Byte adalah tipe nilai yang tidak dapat diubah yang mewakili bilangan bulat yang tidak ditandatangani dengan nilai yang berkisar dari 0 (yang diwakili oleh konstanta Byte.MinValue) hingga 255 (yang diwakili oleh konstanta Byte.MaxValue). .NET juga menyertakan jenis nilai bilangan bulat 8-bit yang ditandatangani, SByte, yang mewakili nilai yang berkisar dari -128 hingga 127.

Menginstansiasi nilai Byte

Anda dapat menginisiasi nilai Byte dengan beberapa cara:

  • Anda dapat mendeklarasikan variabel Byte dan menetapkannya nilai bilangan bulat harfiah yang berada dalam rentang jenis data Byte. Contoh berikut mendeklarasikan dua variabel Byte dan menetapkan nilainya dengan cara ini.

    byte value1 = 64;
    byte value2 = 255;
    
    let value1 = 64uy
    let value2 = 255uy
    
    Dim value1 As Byte = 64
    Dim value2 As Byte = 255
    
  • Anda dapat menetapkan nilai numerik non-byte ke byte. Ini adalah konversi yang mempersempit, sehingga memerlukan operator cast di C# dan F#, atau metode konversi di Visual Basic jika Option Strict aktif. Jika nilai non-byte adalah nilai Single, Double, atau Decimal yang menyertakan komponen pecahan, penanganan bagian pecahannya tergantung pada pengkompilasi yang melakukan konversi. Contoh berikut menetapkan beberapa nilai numerik ke variabel Byte.

    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
    
  • Anda dapat memanggil metode kelas Convert untuk mengonversi jenis yang didukung menjadi nilai Byte. Ini dimungkinkan karena Byte mendukung antarmuka IConvertible. Contoh berikut mengilustrasikan konversi array nilai Int32 ke nilai Byte.

    int[] numbers = { Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue };
    byte result;
    foreach (int number in numbers)
    {
       try {
          result = Convert.ToByte(number);
          Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.",
                            number.GetType().Name, number,
                            result.GetType().Name, result);
       }
       catch (OverflowException) {
          Console.WriteLine("The {0} value {1} is outside the range of the Byte type.",
                            number.GetType().Name, number);
       }
    }
    // The example displays the following output:
    //       The Int32 value -2147483648 is outside the range of the Byte type.
    //       The Int32 value -1 is outside the range of the Byte type.
    //       Converted the Int32 value 0 to the Byte value 0.
    //       Converted the Int32 value 121 to the Byte value 121.
    //       The Int32 value 340 is outside the range of the Byte type.
    //       The Int32 value 2147483647 is outside the range of the Byte type.
    
    let numbers = [| Int32.MinValue; -1; 0; 121; 340; Int32.MaxValue |]
    for number in numbers do
        try
            let result = Convert.ToByte number
            printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
        with :? OverflowException ->
            printfn $"The {number.GetType().Name} value {number} is outside the range of the Byte type."
    // The example displays the following output:
    //       The Int32 value -2147483648 is outside the range of the Byte type.
    //       The Int32 value -1 is outside the range of the Byte type.
    //       Converted the Int32 value 0 to the Byte value 0.
    //       Converted the Int32 value 121 to the Byte value 121.
    //       The Int32 value 340 is outside the range of the Byte type.
    //       The Int32 value 2147483647 is outside the range of the Byte type.
    
    Dim numbers() As Integer = {Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue}
    Dim result As Byte
    For Each number As Integer In numbers
        Try
            result = Convert.ToByte(number)
            Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.",
                          number.GetType().Name, number,
                          result.GetType().Name, result)
        Catch e As OverflowException
            Console.WriteLine("The {0} value {1} is outside the range of the Byte type.",
                          number.GetType().Name, number)
        End Try
    Next
    ' The example displays the following output:
    '       The Int32 value -2147483648 is outside the range of the Byte type.
    '       The Int32 value -1 is outside the range of the Byte type.
    '       Converted the Int32 value 0 to the Byte value 0.
    '       Converted the Int32 value 121 to the Byte value 121.
    '       The Int32 value 340 is outside the range of the Byte type.
    '       The Int32 value 2147483647 is outside the range of the Byte type.
    
  • Anda dapat memanggil metode Parse atau TryParse untuk mengonversi representasi string dari nilai Byte menjadi Byte. String dapat berisi digit desimal atau heksadesimal. Contoh berikut mengilustrasikan operasi penguraian dengan menggunakan string desimal dan heksadesimal.

    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
    

Melakukan operasi pada nilai Byte

Jenis Byte mendukung operasi matematika standar seperti penambahan, pengurangan, pembagian, perkalian, pengurangan, negasi, dan negasi unary. Seperti tipe integral lainnya, tipe Byte juga mendukung operator bitwise AND, OR, XOR, shift kiri, dan shift kanan.

Anda dapat menggunakan operator numerik standar untuk membandingkan dua nilai Byte, atau Anda dapat memanggil metode CompareTo atau Equals.

Anda juga dapat memanggil anggota kelas Math untuk melakukan berbagai operasi numerik, termasuk mendapatkan nilai absolut angka, menghitung kuota dan sisanya dari pembagian integral, menentukan nilai maksimum atau minimum dua bilangan bulat, mendapatkan tanda angka, dan membulatkan angka.

Mewakili Byte sebagai String

Jenis Byte menyediakan dukungan penuh untuk string format numerik standar dan kustom. (Untuk informasi selengkapnya, lihat Jenis Pemformatan, String Format Numerik Standar, dan String Format Numerik Kustom.) Namun, yang paling umum, nilai byte direpresentasikan sebagai nilai satu digit ke tiga digit tanpa pemformatan tambahan, atau sebagai nilai heksadesimal dua digit.

Untuk memformat nilai Byte sebagai string integral tanpa nol di depannya, Anda dapat memanggil metode ToString() tanpa parameter. Dengan menggunakan penentu format "D", Anda juga dapat menyertakan jumlah nol di depan tertentu dalam representasi string. Dengan menggunakan penentu format "X", Anda dapat mewakili nilai Byte sebagai string heksadesimal. Contoh berikut memformat elemen dalam array nilai Byte dengan tiga cara ini.

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

Anda juga dapat memformat nilai Byte sebagai string biner, oktal, desimal, atau heksadesimal dengan memanggil metode ToString(Byte, Int32) dan menyediakan basis sebagai parameter kedua metode. Contoh berikut memanggil metode ini untuk menampilkan representasi biner, oktal, dan heksadesimal dari array nilai 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

Bekerja dengan nilai Byte non-desimal

Selain bekerja dengan byte individual sebagai nilai desimal, Anda mungkin ingin melakukan operasi bitwise dengan nilai byte, atau bekerja dengan array byte atau dengan representasi biner atau heksadesimal dari nilai byte. Misalnya, kelebihan beban metode BitConverter.GetBytes dapat mengonversi masing-masing jenis data primitif menjadi array byte, dan metode BigInteger.ToByteArray mengonversi nilai BigInteger menjadi array byte.

Nilai Byte dinyatakan dalam 8 bit hanya dengan besarnya, tanpa bit tanda. Ini penting untuk diingat ketika Anda melakukan operasi bitwise pada nilai Byte atau ketika Anda bekerja dengan bit individual. Untuk melakukan operasi numerik, Boolean, atau perbandingan pada dua nilai non-desimal, kedua nilai harus menggunakan representasi yang sama.

Saat operasi dilakukan pada dua nilai Byte, nilai berbagi representasi yang sama, sehingga hasilnya akurat. Ini diilustrasikan dalam contoh berikut, yang menutupi bit urutan terendah dari nilai Byte untuk memastikan bahwa itu merata.

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

Di sisi lain, ketika Anda bekerja dengan bit yang tidak ditandatangani dan ditandatangani, operasi bit-bit menjadi rumit karena nilai SByte menggunakan representasi tanda dan besarnya untuk nilai positif, dan representasi pelengkap dua untuk nilai negatif. Untuk melakukan operasi bitwise yang bermakna, nilai harus dikonversi ke dua representasi yang setara, dan informasi tentang bit tanda harus dipertahankan. Contoh berikut melakukan ini untuk menghilangkan bit 2 dan 4 dari array nilai 8-bit bertanda dan tidak bertanda.

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)

Bidang

Nama Deskripsi
MaxValue

Mewakili nilai terbesar yang mungkin dari .Byte Bidang ini konstan.

MinValue

Mewakili nilai sekecil mungkin dari Byte. Bidang ini konstan.

Metode

Nama Deskripsi
Clamp(Byte, Byte, Byte)

Menjepit nilai ke nilai minimum dan maksimum inklusif.

CompareTo(Byte)

Membandingkan instans ini dengan bilangan bulat 8-bit yang tidak ditandatangani dan mengembalikan indikasi nilai relatifnya.

CompareTo(Object)

Membandingkan instans ini dengan objek tertentu dan mengembalikan indikasi nilai relatifnya.

CreateChecked<TOther>(TOther)

Membuat instans jenis saat ini dari nilai, melemparkan pengecualian luapan untuk nilai apa pun yang berada di luar rentang yang dapat diwakili dari jenis saat ini.

CreateSaturating<TOther>(TOther)

Membuat instans jenis saat ini dari nilai, menjenuhkan nilai apa pun yang berada di luar rentang yang dapat diwakili dari jenis saat ini.

CreateTruncating<TOther>(TOther)

Membuat instans jenis saat ini dari nilai, memotong nilai apa pun yang berada di luar rentang yang dapat diwakili dari jenis saat ini.

DivRem(Byte, Byte)

Menghitung kuota dan sisa dari dua nilai.

Equals(Byte)

Mengembalikan nilai yang menunjukkan apakah instans ini dan objek tertentu Byte mewakili nilai yang sama.

Equals(Object)

Mengembalikan nilai yang menunjukkan apakah instans ini sama dengan objek tertentu.

GetHashCode()

Mengembalikan kode hash untuk instans ini.

GetTypeCode()

Mengembalikan TypeCode untuk jenis Bytenilai .

IsEvenInteger(Byte)

Menentukan apakah nilai mewakili angka integral genap.

IsOddInteger(Byte)

Menentukan apakah nilai mewakili angka integral ganjil.

IsPow2(Byte)

Menentukan apakah nilai adalah kekuatan dua.

LeadingZeroCount(Byte)

Menghitung jumlah nol di depan dalam sebuah nilai.

Log10(Byte)

Mewakili bilangan bulat yang tidak ditandatangani 8-bit.

Log2(Byte)

Menghitung log2 dari nilai.

Max(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang lebih besar.

Min(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang lebih rendah.

Parse(ReadOnlySpan<Byte>, IFormatProvider)

Mengurai rentang karakter UTF-8 menjadi nilai.

Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider)

Mengurai rentang karakter UTF-8 menjadi nilai.

Parse(ReadOnlySpan<Char>, IFormatProvider)

Mengurai rentang karakter menjadi nilai.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

Mengonversi representasi rentang angka dalam gaya tertentu dan format khusus budaya menjadi Byte setara.

Parse(String, IFormatProvider)

Mengonversi representasi string dari angka dalam format khusus budaya tertentu ke Byte yang setara.

Parse(String, NumberStyles, IFormatProvider)

Mengonversi representasi string dari angka dalam gaya tertentu dan format khusus budaya menjadi Byte setara.

Parse(String, NumberStyles)

Mengonversi representasi string dari angka dalam gaya tertentu ke Byte yang setara.

Parse(String)

Mengonversi representasi string dari angka menjadi Byte setara.

PopCount(Byte)

Menghitung jumlah bit yang diatur dalam nilai.

RotateLeft(Byte, Int32)

Memutar nilai yang ditinggalkan oleh jumlah tertentu.

RotateRight(Byte, Int32)

Memutar nilai tepat dengan jumlah tertentu.

Sign(Byte)

Menghitung tanda nilai.

ToString()

Mengonversi nilai objek saat ini Byte ke representasi string yang setara.

ToString(IFormatProvider)

Mengonversi nilai numerik objek saat ini Byte ke representasi string yang setara menggunakan informasi pemformatan khusus budaya yang ditentukan.

ToString(String, IFormatProvider)

Mengonversi nilai objek saat ini Byte ke representasi string yang setara menggunakan format yang ditentukan dan informasi pemformatan khusus budaya.

ToString(String)

Mengonversi nilai objek saat ini Byte ke representasi string yang setara menggunakan format yang ditentukan.

TrailingZeroCount(Byte)

Menghitung jumlah nol berikutnya dalam sebuah nilai.

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

Mencoba memformat nilai instans saat ini sebagai UTF-8 ke dalam rentang byte yang disediakan.

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

Mencoba memformat nilai instans bilangan bulat 8-bit yang tidak ditandatangani saat ini ke dalam rentang karakter yang disediakan.

TryParse(ReadOnlySpan<Byte>, Byte)

Mencoba mengonversi rentang karakter UTF-8 yang berisi representasi string angka ke bilangan bulat yang tidak ditandatangani 8-bit yang setara.

TryParse(ReadOnlySpan<Byte>, IFormatProvider, Byte)

Mencoba mengurai rentang karakter UTF-8 ke dalam nilai.

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

Mencoba mengurai rentang karakter UTF-8 ke dalam nilai.

TryParse(ReadOnlySpan<Char>, Byte)

Mencoba mengonversi representasi rentang angka menjadi Byte setara, dan mengembalikan nilai yang menunjukkan apakah konversi berhasil.

TryParse(ReadOnlySpan<Char>, IFormatProvider, Byte)

Mencoba mengurai rentang karakter menjadi nilai.

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

Mengonversi representasi rentang angka dalam gaya tertentu dan format khusus budaya menjadi Byte setara. Nilai pengembalian menunjukkan apakah konversi berhasil atau gagal.

TryParse(String, Byte)

Mencoba mengonversi representasi string dari angka ke Byte yang setara, dan mengembalikan nilai yang menunjukkan apakah konversi berhasil.

TryParse(String, IFormatProvider, Byte)

Mencoba mengurai string ke dalam nilai.

TryParse(String, NumberStyles, IFormatProvider, Byte)

Mengonversi representasi string dari angka dalam gaya tertentu dan format khusus budaya menjadi Byte setara. Nilai pengembalian menunjukkan apakah konversi berhasil atau gagal.

Implementasi Antarmuka Eksplisit

Nama Deskripsi
IAdditionOperators<Byte,Byte,Byte>.Addition(Byte, Byte)

Menambahkan dua nilai bersama-sama untuk menghitung jumlahnya.

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

Menambahkan dua nilai bersama-sama untuk menghitung jumlahnya.

IAdditiveIdentity<Byte,Byte>.AdditiveIdentity

Mendapatkan identitas aditif dari jenis saat ini.

IBinaryInteger<Byte>.GetByteCount()

Mendapatkan jumlah byte yang akan ditulis sebagai bagian TryWriteLittleEndian(Span<Byte>, Int32)dari .

IBinaryInteger<Byte>.GetShortestBitLength()

Mendapatkan panjang, dalam bit, dari representasi pelengkap dua terpendek dari nilai saat ini.

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

Mewakili bilangan bulat yang tidak ditandatangani 8-bit.

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

Mewakili bilangan bulat yang tidak ditandatangani 8-bit.

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

Mencoba menulis nilai saat ini, dalam format big-endian, ke rentang tertentu.

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

Mencoba menulis nilai saat ini, dalam format little-endian, ke rentang tertentu.

IBinaryNumber<Byte>.AllBitsSet

Mendapatkan instans jenis biner tempat semua bit diatur.

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

Menghitung bitwise-dan dari dua nilai.

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

Menghitung bitwise-atau dari dua nilai.

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

Menghitung nilai eksklusif atau dari dua nilai.

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

Menghitung representasi pelengkap seseorang dari nilai tertentu.

IComparable.CompareTo(Object)

Membandingkan instans saat ini dengan objek lain dengan jenis yang sama dan mengembalikan bilangan bulat yang menunjukkan apakah instans saat ini mendahului, mengikuti, atau terjadi dalam posisi yang sama dalam urutan pengurutan seperti objek lainnya.

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

Membandingkan dua nilai untuk menentukan mana yang lebih besar.

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

Membandingkan dua nilai untuk menentukan mana yang lebih besar atau sama.

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

Membandingkan dua nilai untuk menentukan mana yang kurang.

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

Membandingkan dua nilai untuk menentukan mana yang kurang atau sama.

IConvertible.GetTypeCode()

Mengembalikan untuk instans TypeCode ini.

IConvertible.ToBoolean(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToBoolean(IFormatProvider).

IConvertible.ToByte(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToByte(IFormatProvider).

IConvertible.ToChar(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToChar(IFormatProvider).

IConvertible.ToDateTime(IFormatProvider)

Konversi ini tidak didukung. Mencoba menggunakan metode ini melempar .InvalidCastException

IConvertible.ToDecimal(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToDecimal(IFormatProvider).

IConvertible.ToDouble(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToDouble(IFormatProvider).

IConvertible.ToInt16(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToInt16(IFormatProvider).

IConvertible.ToInt32(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToInt32(IFormatProvider).

IConvertible.ToInt64(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToInt64(IFormatProvider).

IConvertible.ToSByte(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToSByte(IFormatProvider).

IConvertible.ToSingle(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToSingle(IFormatProvider).

IConvertible.ToType(Type, IFormatProvider)

Untuk deskripsi anggota ini, lihat ToType(Type, IFormatProvider).

IConvertible.ToUInt16(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToUInt16(IFormatProvider).

IConvertible.ToUInt32(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToUInt32(IFormatProvider).

IConvertible.ToUInt64(IFormatProvider)

Untuk deskripsi anggota ini, lihat ToUInt64(IFormatProvider).

IDecrementOperators<Byte>.CheckedDecrement(Byte)

Mengurangi nilai.

IDecrementOperators<Byte>.Decrement(Byte)

Mengurangi nilai.

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

Membagi satu nilai dengan nilai lainnya untuk menghitung kuotanya.

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

Membandingkan dua nilai untuk menentukan kesetaraan.

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

Membandingkan dua nilai untuk menentukan ketidaksetaraan.

IIncrementOperators<Byte>.CheckedIncrement(Byte)

Menaikkan nilai.

IIncrementOperators<Byte>.Increment(Byte)

Menaikkan nilai.

IMinMaxValue<Byte>.MaxValue

Mendapatkan nilai maksimum dari jenis saat ini.

IMinMaxValue<Byte>.MinValue

Mendapatkan nilai minimum dari jenis saat ini.

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

Membagi dua nilai bersama-sama untuk menghitung modulus atau sisanya.

IMultiplicativeIdentity<Byte,Byte>.MultiplicativeIdentity

Mendapatkan identitas multiplikatif dari jenis saat ini.

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

Mengalikan dua nilai bersama-sama untuk menghitung produknya.

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

Mengalikan dua nilai bersama-sama untuk menghitung produknya.

INumber<Byte>.CopySign(Byte, Byte)

Menyalin tanda nilai ke tanda nilai lain.

INumber<Byte>.MaxNumber(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang lebih besar dan mengembalikan nilai lain jika input adalah NaN.

INumber<Byte>.MinNumber(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang lebih kecil dan mengembalikan nilai lain jika input adalah NaN.

INumberBase<Byte>.Abs(Byte)

Menghitung absolut nilai.

INumberBase<Byte>.IsCanonical(Byte)

Menentukan apakah nilai berada dalam representasi kanonisnya.

INumberBase<Byte>.IsComplexNumber(Byte)

Menentukan apakah nilai mewakili bilangan kompleks.

INumberBase<Byte>.IsFinite(Byte)

Menentukan apakah nilai terbatas.

INumberBase<Byte>.IsImaginaryNumber(Byte)

Menentukan apakah nilai mewakili angka imajiner murni.

INumberBase<Byte>.IsInfinity(Byte)

Menentukan apakah nilai tidak terbatas.

INumberBase<Byte>.IsInteger(Byte)

Menentukan apakah nilai mewakili angka integral.

INumberBase<Byte>.IsNaN(Byte)

Menentukan apakah nilainya adalah NaN.

INumberBase<Byte>.IsNegative(Byte)

Menentukan apakah nilai negatif.

INumberBase<Byte>.IsNegativeInfinity(Byte)

Menentukan apakah nilai adalah tak terbatas negatif.

INumberBase<Byte>.IsNormal(Byte)

Menentukan apakah nilai normal.

INumberBase<Byte>.IsPositive(Byte)

Menentukan apakah nilai positif.

INumberBase<Byte>.IsPositiveInfinity(Byte)

Menentukan apakah nilai adalah tak terbatas positif.

INumberBase<Byte>.IsRealNumber(Byte)

Menentukan apakah nilai mewakili angka riil.

INumberBase<Byte>.IsSubnormal(Byte)

Menentukan apakah nilai adalah subnormal.

INumberBase<Byte>.IsZero(Byte)

Menentukan apakah nilai adalah nol.

INumberBase<Byte>.MaxMagnitude(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang lebih besar.

INumberBase<Byte>.MaxMagnitudeNumber(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang memiliki besaran lebih besar dan mengembalikan nilai lain jika input adalah NaN.

INumberBase<Byte>.MinMagnitude(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang lebih rendah.

INumberBase<Byte>.MinMagnitudeNumber(Byte, Byte)

Membandingkan dua nilai dengan komputasi yang memiliki besaran lebih kecil dan mengembalikan nilai lain jika input adalah NaN.

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

Menghitung perkiraan (left * right) + . addend

INumberBase<Byte>.One

Mendapatkan nilai 1 untuk jenis tersebut.

INumberBase<Byte>.Radix

Mendapatkan radix, atau basis, untuk tipe tersebut.

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

Mewakili bilangan bulat yang tidak ditandatangani 8-bit.

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

Mewakili bilangan bulat yang tidak ditandatangani 8-bit.

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

Mewakili bilangan bulat yang tidak ditandatangani 8-bit.

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

Mencoba mengonversi instans jenis saat ini ke jenis lain, melemparkan pengecualian luapan untuk nilai apa pun yang berada di luar rentang yang dapat diwakili dari jenis saat ini.

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

Mencoba mengonversi instans jenis saat ini ke jenis lain, menjenuhkan nilai apa pun yang berada di luar rentang yang dapat diwakili dari jenis saat ini.

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

Mencoba mengonversi instans jenis saat ini ke jenis lain, memotong nilai apa pun yang berada di luar rentang yang dapat diwakili dari jenis saat ini.

INumberBase<Byte>.Zero

Mendapatkan nilai 0 untuk jenis tersebut.

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

Menggeser nilai yang ditinggalkan oleh jumlah tertentu.

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

Menggeser nilai ke kanan dengan jumlah tertentu.

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

Menggeser nilai ke kanan dengan jumlah tertentu.

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

Mengurangi dua nilai untuk menghitung perbedaannya.

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

Mengurangi dua nilai untuk menghitung perbedaannya.

IUnaryNegationOperators<Byte,Byte>.CheckedUnaryNegation(Byte)

Menghitung negasi nilai unary yang diperiksa.

IUnaryNegationOperators<Byte,Byte>.UnaryNegation(Byte)

Menghitung negasi nilai yang tidak biasa.

IUnaryPlusOperators<Byte,Byte>.UnaryPlus(Byte)

Menghitung nilai plus unary.

Berlaku untuk

Keamanan Thread

Semua anggota jenis ini aman utas. Anggota yang tampaknya mengubah status instans benar-benar mengembalikan instans baru yang diinisialisasi dengan nilai baru. Seperti halnya jenis lain, membaca dan menulis ke variabel bersama yang berisi instans jenis ini harus dilindungi oleh kunci untuk menjamin keamanan utas.

Lihat juga