Byte Struktura

Definicja

Reprezentuje 8-bitową liczbę całkowitą bez znaku.

public value class System::Byte : IComparable, IComparable<System::Byte>, IConvertible, IEquatable<System::Byte>, IFormattable
public value class System::Byte : IComparable, IComparable<System::Byte>, IConvertible, IEquatable<System::Byte>, ISpanFormattable
public value class System::Byte : IComparable, IConvertible, IFormattable
public value class System::Byte : IComparable, IComparable<System::Byte>, IEquatable<System::Byte>, IFormattable
public struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, IFormattable
public struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, ISpanFormattable
[System.Serializable]
public struct Byte : IComparable, IConvertible, IFormattable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public struct Byte : IComparable, IComparable<byte>, IConvertible, IEquatable<byte>, IFormattable
public struct Byte : IComparable, IComparable<byte>, IEquatable<byte>, IFormattable
type byte = struct
    interface IConvertible
    interface IFormattable
type byte = struct
    interface IConvertible
    interface ISpanFormattable
    interface IFormattable
[<System.Serializable>]
type byte = struct
    interface IFormattable
    interface IConvertible
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type byte = struct
    interface IFormattable
    interface IConvertible
type byte = struct
    interface IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IConvertible, IEquatable(Of Byte), IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IConvertible, IEquatable(Of Byte), ISpanFormattable
Public Structure Byte
Implements IComparable, IConvertible, IFormattable
Public Structure Byte
Implements IComparable, IComparable(Of Byte), IEquatable(Of Byte), IFormattable
Dziedziczenie
Atrybuty
Implementuje

Uwagi

Byte jest niezmiennym typem wartości reprezentującym niepodpisane liczby całkowite z wartościami z zakresu od 0 (który jest reprezentowany przez stałą) do Byte.MinValue 255 (reprezentowanych przez Byte.MaxValue stałą). .NET zawiera również typ wartości 8-bitowej liczby całkowitej ze podpisem , który reprezentuje wartości z zakresu SByte od -128 do 127.

Utworzenie wystąpienia wartości bajtowej

Można utworzyć wystąpienia wartości Byte na kilka sposobów:

  • Możesz zadeklarować zmienną i przypisać jej wartość całkowitą literału, która znajduje się w Byte zakresie typu Byte danych. Poniższy przykład deklaruje dwie Byte zmienne i przypisuje im wartości w ten sposób.

    byte value1 = 64;
    byte value2 = 255;
    
    let value1 = 64uy
    let value2 = 255uy
    
    Dim value1 As Byte = 64
    Dim value2 As Byte = 255
    
  • Do bajtu można przypisać wartość liczbową bez bajtów. Jest to konwersja zawężaca, więc wymaga operatora rzutowania w językach C# i F# lub metody konwersji w Visual Basic Option Strict jeśli jest wł. Jeśli wartość nie-bajtowa to wartość typu , lub , która zawiera składnik ułamkowy, obsługa jej części ułamkowej zależy od kompilatora Single Double Decimal wykonującego konwersję. Poniższy przykład przypisuje kilka wartości liczbowych do Byte zmiennych.

    int int1 = 128;
    try {
       byte value1 = (byte) int1;
       Console.WriteLine(value1);
    }
    catch (OverflowException) {
       Console.WriteLine("{0} is out of range of a byte.", int1);
    }
    
    double dbl2 = 3.997;
    try {
       byte value2 = (byte) dbl2;
       Console.WriteLine(value2);
    }
    catch (OverflowException) {
       Console.WriteLine("{0} is out of range of a byte.", dbl2);
    }
    // The example displays the following output:
    //       128
    //       3
    
    let int1 = 128
    try
        let value1 = byte int1
        printfn $"{value1}"
    with :? OverflowException ->
        printfn $"{int1} is out of range of a byte."
    
    let dbl2 = 3.997
    try
        let value2 = byte dbl2
        printfn $"{value2}"
    with :? OverflowException ->
        printfn $"{dbl2} is out of range of a byte."
    
    // The example displays the following output:
    //       128
    //       3
    
    Dim int1 As Integer = 128
    Try
       Dim value1 As Byte = CByte(int1)
       Console.WriteLine(value1)
    Catch e As OverflowException
       Console.WriteLine("{0} is out of range of a byte.", int1)
    End Try
    
    Dim dbl2 As Double = 3.997
    Try
       Dim value2 As Byte = CByte(dbl2)
       Console.WriteLine(value2)
    Catch e As OverflowException
       Console.WriteLine("{0} is out of range of a byte.", dbl2)
    End Try   
    ' The example displays the following output:
    '       128
    '       4
    
  • Możesz wywołać metodę klasy Convert , aby przekonwertować dowolny obsługiwany typ na Byte wartość. Jest to możliwe, ponieważ Byte obsługuje IConvertible interfejs . Poniższy przykład ilustruje konwersję tablicy wartości Int32 na Byte wartości.

    int[] numbers = { Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue };
    byte result;
    foreach (int number in numbers)
    {
       try {
          result = Convert.ToByte(number);
          Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.",
                            number.GetType().Name, number,
                            result.GetType().Name, result);
       }
       catch (OverflowException) {
          Console.WriteLine("The {0} value {1} is outside the range of the Byte type.",
                            number.GetType().Name, number);
       }
    }
    // The example displays the following output:
    //       The Int32 value -2147483648 is outside the range of the Byte type.
    //       The Int32 value -1 is outside the range of the Byte type.
    //       Converted the Int32 value 0 to the Byte value 0.
    //       Converted the Int32 value 121 to the Byte value 121.
    //       The Int32 value 340 is outside the range of the Byte type.
    //       The Int32 value 2147483647 is outside the range of the Byte type.
    
    open System
    
    let numbers = [| Int32.MinValue; -1; 0; 121; 340; Int32.MaxValue |]
    
    for number in numbers do
        try
            let result = Convert.ToByte number
            printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
    
        with :? OverflowException ->
            printfn $"The {number.GetType().Name} value {number} is outside the range of the Byte type."
    
    
    // The example displays the following output:
    //       The Int32 value -2147483648 is outside the range of the Byte type.
    //       The Int32 value -1 is outside the range of the Byte type.
    //       Converted the Int32 value 0 to the Byte value 0.
    //       Converted the Int32 value 121 to the Byte value 121.
    //       The Int32 value 340 is outside the range of the Byte type.
    //       The Int32 value 2147483647 is outside the range of the Byte type.
    
    Dim numbers() As Integer = { Int32.MinValue, -1, 0, 121, 340, Int32.MaxValue }
    Dim result As Byte
    For Each number As Integer In numbers
       Try
          result = Convert.ToByte(number)
          Console.WriteLIne("Converted the {0} value {1} to the {2} value {3}.", _
                            number.GetType().Name, number, _
                            result.GetType().Name, result)
       Catch e As OverflowException
          Console.WriteLine("The {0} value {1} is outside the range of the Byte type.", _
                            number.GetType().Name, number)
       End Try
    Next
    ' The example displays the following output:
    '       The Int32 value -2147483648 is outside the range of the Byte type.
    '       The Int32 value -1 is outside the range of the Byte type.
    '       Converted the Int32 value 0 to the Byte value 0.
    '       Converted the Int32 value 121 to the Byte value 121.
    '       The Int32 value 340 is outside the range of the Byte type.
    '       The Int32 value 2147483647 is outside the range of the Byte type.
    
  • Możesz wywołać metodę Parse lub TryParse , aby przekonwertować ciągową Byte reprezentację wartości na Byte . Ciąg może zawierać cyfry dziesiętne lub szesnastkową. Poniższy przykład ilustruje operację analizowania przy użyciu zarówno ciągu dziesiętnego, jak i szesnastkowego.

    string string1 = "244";
    try {
       byte byte1 = Byte.Parse(string1);
       Console.WriteLine(byte1);
    }
    catch (OverflowException) {
       Console.WriteLine("'{0}' is out of range of a byte.", string1);
    }
    catch (FormatException) {
       Console.WriteLine("'{0}' is out of range of a byte.", string1);
    }
    
    string string2 = "F9";
    try {
       byte byte2 = Byte.Parse(string2,
                               System.Globalization.NumberStyles.HexNumber);
       Console.WriteLine(byte2);
    }
    catch (OverflowException) {
       Console.WriteLine("'{0}' is out of range of a byte.", string2);
    }
    catch (FormatException) {
       Console.WriteLine("'{0}' is out of range of a byte.", string2);
    }
    // The example displays the following output:
    //       244
    //       249
    
    let string1 = "244"
    try
        let byte1 = Byte.Parse string1
        printfn $"{byte1}" 
    with
    | :? OverflowException ->
        printfn $"'{string1}' is out of range of a byte."
    | :? FormatException ->
        printfn $"'{string1}' is out of range of a byte."
    
    let string2 = "F9"
    try
        let byte2 = Byte.Parse(string2, System.Globalization.NumberStyles.HexNumber)
        printfn $"{byte2}"
    with
    | :? OverflowException ->
        printfn $"'{string2}' is out of range of a byte."
    | :? FormatException ->
        printfn $"'{string2}' is out of range of a byte."
    
    // The example displays the following output:
    //       244
    //       249
    
    Dim string1 As String = "244"
    Try
       Dim byte1 As Byte = Byte.Parse(string1)
       Console.WriteLine(byte1)
    Catch e As OverflowException
       Console.WriteLine("'{0}' is out of range of a byte.", string1)
    Catch e As FormatException
       Console.WriteLine("'{0}' is out of range of a byte.", string1)
    End Try
    
    Dim string2 As String = "F9"
    Try
       Dim byte2 As Byte = Byte.Parse(string2,
                                 System.Globalization.NumberStyles.HexNumber)
       Console.WriteLine(byte2)
    Catch e As OverflowException
       Console.WriteLine("'{0}' is out of range of a byte.", string2)
    Catch e As FormatException
       Console.WriteLine("'{0}' is out of range of a byte.", string2)
    End Try
    ' The example displays the following output:
    '       244
    '       249
    

Wykonywanie operacji na wartościach bajtowych

Typ obsługuje standardowe operacje matematyczne, takie jak dodawanie, odejmowanie, dzielenie, mnożenie, odejmowanie, negacja i Byte negacja jednoznaczna. Podobnie jak inne typy całkowite, typ obsługuje Byte również operatory przesunięcia bitowego, , , przesunięcia w lewo AND i w OR XOR prawo.

Możesz użyć standardowych operatorów liczbowych do porównania dwóch wartości Byte lub wywołać metodę lub CompareTo Equals .

Można również wywołać składowe klasy w celu wykonania szerokiego zakresu operacji liczbowych, w tym uzyskiwania wartości bezwzględnej liczby, obliczania ilorazu i reszty z dzielenia całkowitego, określania maksymalnej lub minimalnej wartości dwóch liczb całkowitych, uzyskiwania znaku liczby i zaokrąglania Math liczby.

Reprezentowanie bajta jako ciągu

Typ zapewnia pełną obsługę standardowych i Byte niestandardowych ciągów formatu liczb. (Aby uzyskać więcej informacji, zobacz Typy formatowania, Standardowe ciągi formatu liczbowegoi Niestandardowe ciągi formatu liczbowego). Jednak najczęściej wartości bajtowe są reprezentowane jako wartości jednocyfrowe lub trzycyfrowe bez dodatkowego formatowania lub dwucyfrowych wartości szesnastkowych.

Aby sformatować Byte wartość jako ciąg całkowitowartościowy bez zer wiodących, możesz wywołać metodę bez ToString() parametrów. Za pomocą specyfikatora formatu "D" można również uwzględnić określoną liczbę zer wiodących w reprezentacji ciągu. Za pomocą specyfikatora formatu "X" można reprezentować wartość Byte jako ciąg szesnastkowym. Poniższy przykład formatuje elementy w tablicy Byte wartości na te trzy sposoby.

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

Można również sformatować wartość jako ciąg binarny, ósemkowy, dziesiętny lub szesnastkowy, wywołując metodę i dostarczając bazę jako Byte ToString(Byte, Int32) drugi parametr metody. Poniższy przykład wywołuje tę metodę w celu wyświetlenia reprezentacji binarnych, ósemkowym i szesnastkowym tablicy wartości bajtowych.

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

Praca z niedziesiętnymi wartościami bajtowymi

Oprócz pracy z poszczególnymi bajtami jako wartościami dziesiętnych można wykonywać operacje bitowe z wartościami bajtów lub pracować z tablicami bajtów albo z binarnymi lub szesnastkowymi reprezentacjami wartości bajtowych. Na przykład przeciążenia metody mogą konwertować poszczególne typy danych pierwotnych na tablicę bajtów, a metoda konwertuje wartość na BitConverter.GetBytes BigInteger.ToByteArray BigInteger tablicę bajtów.

Byte Wartości są reprezentowane w 8 bitach tylko przez ich wielkość, bez bitu znaku. Należy o tym pamiętać podczas wykonywania operacji bitowych na wartościach lub pracy z Byte poszczególnymi bitami. Aby wykonać operację liczbową, logiczną lub operację porównywania na dwóch wartościach niedziesiętnych, obie wartości muszą używać tej samej reprezentacji.

Gdy operacja jest wykonywana na dwóch wartościach, wartości mają tę samą reprezentację, więc Byte wynik jest dokładny. Jest to zilustrowane w poniższym przykładzie, który maskuje bit wartości o najniższej kolejności, aby upewnić się, Byte że jest on równomierny.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      string[] values = { Convert.ToString(12, 16),
                          Convert.ToString(123, 16),
                          Convert.ToString(245, 16) };

      byte mask = 0xFE;
      foreach (string value in values) {
         Byte byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier);
         Console.WriteLine("{0} And {1} = {2}", byteValue, mask,
                           byteValue & mask);
      }
   }
}
// The example displays the following output:
//       12 And 254 = 12
//       123 And 254 = 122
//       245 And 254 = 244
open System
open System.Globalization

let values = 
    [ Convert.ToString(12, 16)
      Convert.ToString(123, 16)
      Convert.ToString(245, 16) ]

let mask = 0xFEuy
for value in values do
    let byteValue = Byte.Parse(value, NumberStyles.AllowHexSpecifier)
    printfn $"{byteValue} And {mask} = {byteValue &&& mask}"
                    

// The example displays the following output:
//       12 And 254 = 12
//       123 And 254 = 122
//       245 And 254 = 244
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim values() As String = { Convert.ToString(12, 16), _
                                 Convert.ToString(123, 16), _
                                 Convert.ToString(245, 16) }
      
      Dim mask As Byte = &hFE
      For Each value As String In values
         Dim byteValue As Byte = Byte.Parse(value, NumberStyles.AllowHexSpecifier)
         Console.WriteLine("{0} And {1} = {2}", byteValue, mask, _ 
                           byteValue And mask)
      Next         
   End Sub
End Module
' The example displays the following output:
'       12 And 254 = 12
'       123 And 254 = 122
'       245 And 254 = 244

Z drugiej strony podczas pracy z bitami bez znaku i ze znakiem operacje bitowe są skomplikowane przez fakt, że wartości używają reprezentacji znaku i wielkości dla wartości dodatnich oraz reprezentacji dopełnień dwóch dla wartości SByte ujemnych. Aby można było wykonać znaczącą operację bitową, wartości muszą zostać przekonwertowane na dwie równoważne reprezentacje, a informacje o bitach znaku muszą zostać zachowane. W poniższym przykładzie jest to robione w celu maskowania bitów 2 i 4 tablicy 8-bitowych wartości ze podpisem i bez podpisów.

using System;
using System.Collections.Generic;
using System.Globalization;

public struct ByteString
{
   public string Value;
   public int Sign;
}

public class Example
{
   public static void Main()
   {
      ByteString[] values = CreateArray(-15, 123, 245);

      byte mask = 0x14;        // Mask all bits but 2 and 4.

      foreach (ByteString strValue in values) {
         byte byteValue = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier);
         Console.WriteLine("{0} ({1}) And {2} ({3}) = {4} ({5})",
                           strValue.Sign * byteValue,
                           Convert.ToString(byteValue, 2),
                           mask, Convert.ToString(mask, 2),
                           (strValue.Sign & Math.Sign(mask)) * (byteValue & mask),
                           Convert.ToString(byteValue & mask, 2));
      }
   }

   private static ByteString[] CreateArray(params int[] values)
   {
      List<ByteString> byteStrings = new List<ByteString>();

      foreach (object value in values) {
         ByteString temp = new ByteString();
         int sign = Math.Sign((int) value);
         temp.Sign = sign;

         // Change two's complement to magnitude-only representation.
         temp.Value = Convert.ToString(((int) value) * sign, 16);

         byteStrings.Add(temp);
      }
      return byteStrings.ToArray();
   }
}
// The example displays the following output:
//       -15 (1111) And 20 (10100) = 4 (100)
//       123 (1111011) And 20 (10100) = 16 (10000)
//       245 (11110101) And 20 (10100) = 20 (10100)
open System
open System.Collections.Generic
open System.Globalization

[<Struct>]
type ByteString =
    { Sign: int
      Value: string }

let createArray values =
    [ for value in values do
        let sign = sign value
        { Sign = sign
         // Change two's complement to magnitude-only representation.
          Value = Convert.ToString(value * sign, 16)} ]


let values = createArray [ -15; 123; 245 ]

let mask = 0x14uy        // Mask all bits but 2 and 4.

for strValue in values do
    let byteValue = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier)
    printfn $"{strValue.Sign * int byteValue} ({Convert.ToString(byteValue, 2)}) And {mask} ({Convert.ToString(mask, 2)}) = {(strValue.Sign &&& (int mask |> sign)) * int (byteValue &&& mask)} ({Convert.ToString(byteValue &&& mask, 2)})"

// The example displays the following output:
//       -15 (1111) And 20 (10100) = 4 (100)
//       123 (1111011) And 20 (10100) = 16 (10000)
//       245 (11110101) And 20 (10100) = 20 (10100)
Imports System.Collections.Generic
Imports System.Globalization

Public Structure ByteString
   Public Value As String
   Public Sign As Integer
End Structure

Module Example
   Public Sub Main()
      Dim values() As ByteString = CreateArray(-15, 123, 245)
      
      Dim mask As Byte = &h14        ' Mask all bits but 2 and 4.
      
      For Each strValue As ByteString In values
         Dim byteValue As Byte = Byte.Parse(strValue.Value, NumberStyles.AllowHexSpecifier)
         Console.WriteLine("{0} ({1}) And {2} ({3}) = {4} ({5})", _ 
                           strValue.Sign * byteValue, _ 
                           Convert.ToString(byteValue, 2), _
                           mask, Convert.ToString(mask, 2), _
                           (strValue.Sign And Math.Sign(mask)) * (byteValue And mask), _
                           Convert.ToString(byteValue And mask, 2))
      Next         
   End Sub
   
   Private Function CreateArray(ParamArray values() As Object) As ByteString()
      Dim byteStrings As New List(Of ByteString)
      For Each value As Object In values
         Dim temp As New ByteString()
         Dim sign As Integer = Math.Sign(value)
         temp.Sign = sign
         ' Change two's complement to magnitude-only representation.
         value = value * sign

         temp.Value = Convert.ToString(value, 16)
         byteStrings.Add(temp)
      Next
      Return byteStrings.ToArray()
   End Function   
End Module
' The example displays the following output:
'       -15 (1111) And 20 (10100) = 4 (100)
'       123 (1111011) And 20 (10100) = 16 (10000)
'       245 (11110101) And 20 (10100) = 20 (10100)

Pola

MaxValue

Reprezentuje największą możliwą wartość Byte . To pole jest stałe.

MinValue

Reprezentuje najmniejszą możliwą Byte wartość . To pole jest stałe.

Metody

CompareTo(Byte)

Porównuje to wystąpienie z określoną 8-bitową liczbą całkowitą bez znaku i zwraca wskazanie ich wartości względnych.

CompareTo(Object)

Porównuje to wystąpienie z określonym obiektem i zwraca wskazanie ich względnych wartości.

Equals(Byte)

Zwraca wartość wskazującą, czy to wystąpienie i określony Byte obiekt reprezentują tę samą wartość.

Equals(Object)

Zwraca wartość wskazującą, czy to wystąpienie jest równe podanemu obiektowi.

GetHashCode()

Zwraca wartość skrótu dla tego wystąpienia.

GetTypeCode()

Zwraca typ TypeCode wartości Byte dla .

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

Konwertuje reprezentację zakresu liczby w określonym stylu i formacie specyficznym dla kultury na jej Byte odpowiednik.

Parse(String)

Konwertuje reprezentację ciągu liczby na jej Byte odpowiednik.

Parse(String, IFormatProvider)

Konwertuje reprezentację ciągu liczby w określonym formacie specyficznym dla kultury na jej Byte odpowiednik.

Parse(String, NumberStyles)

Konwertuje reprezentację ciągu liczby w określonym stylu na jej Byte odpowiednik.

Parse(String, NumberStyles, IFormatProvider)

Konwertuje reprezentację ciągu liczby w określonym stylu i formacie specyficznym dla kultury na jej Byte odpowiednik.

ToString()

Konwertuje wartość bieżącego obiektu Byte na równoważną reprezentację ciągu.

ToString(IFormatProvider)

Konwertuje wartość liczbową bieżącego obiektu na równoważną reprezentację ciągu Byte przy użyciu określonych informacji o formatowaniu specyficznych dla kultury.

ToString(String)

Konwertuje wartość bieżącego obiektu na równoważną reprezentację Byte ciągu przy użyciu określonego formatu.

ToString(String, IFormatProvider)

Konwertuje wartość bieżącego obiektu na równoważną reprezentację ciągu przy użyciu określonego formatu i Byte informacji o formatowaniu specyficznym dla kultury.

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

Próbuje sformatować wartość bieżącego 8-bitowego wystąpienia liczby całkowitej bez znaku do podanego zakresu znaków.

TryParse(ReadOnlySpan<Char>, Byte)

Próbuje przekonwertować reprezentację zakresu liczby na jej odpowiednik i zwraca wartość, która wskazuje, Byte czy konwersja zakończyła się pomyślnie.

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

Konwertuje reprezentację zakresu liczby w określonym stylu i formacie specyficznym dla kultury na jej Byte odpowiednik. Zwracana wartość wskazuje, czy konwersja powiodła się czy nie.

TryParse(String, Byte)

Próbuje przekonwertować ciąg reprezentacji liczby na jej odpowiednik i zwraca wartość, która wskazuje, Byte czy konwersja zakończyła się pomyślnie.

TryParse(String, NumberStyles, IFormatProvider, Byte)

Konwertuje reprezentację ciągu liczby w określonym stylu i formacie specyficznym dla kultury na jej Byte odpowiednik. Zwracana wartość wskazuje, czy konwersja powiodła się czy nie.

Jawne implementacje interfejsu

IComparable.CompareTo(Object)

Porównuje bieżące wystąpienie z innym obiektem tego samego typu i zwraca liczbę całkowitą, która wskazuje, czy bieżące wystąpienie poprzedza, następuje po lub występuje w tym samym położeniu, co inny obiekt w porządku sortowania.

IConvertible.GetTypeCode()

Zwraca wartość TypeCode dla tego wystąpienia.

IConvertible.ToBoolean(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToBoolean(IFormatProvider) .

IConvertible.ToByte(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToByte(IFormatProvider) .

IConvertible.ToChar(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToChar(IFormatProvider) .

IConvertible.ToDateTime(IFormatProvider)

Ta konwersja nie jest obsługiwana. Próba użycia tej metody zgłasza wyjątek InvalidCastException .

IConvertible.ToDecimal(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToDecimal(IFormatProvider) .

IConvertible.ToDouble(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToDouble(IFormatProvider) .

IConvertible.ToInt16(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToInt16(IFormatProvider) .

IConvertible.ToInt32(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToInt32(IFormatProvider) .

IConvertible.ToInt64(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToInt64(IFormatProvider) .

IConvertible.ToSByte(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToSByte(IFormatProvider) .

IConvertible.ToSingle(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToSingle(IFormatProvider) .

IConvertible.ToType(Type, IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToType(Type, IFormatProvider) .

IConvertible.ToUInt16(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToUInt16(IFormatProvider) .

IConvertible.ToUInt32(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToUInt32(IFormatProvider) .

IConvertible.ToUInt64(IFormatProvider)

Aby uzyskać opis tego członka, zobacz ToUInt64(IFormatProvider) .

Dotyczy

Bezpieczeństwo wątkowe

Wszystkie elementy członkowskie tego typu są bezpieczne wątkowo. Elementy członkowskie, które na pierwszy rzut oka modyfikują stan wystąpienia, w rzeczywistości zwracają nowe wystąpienie zainicjowane z nową wartością. Podobnie jak w przypadku innych typów odczytywanie i zapisywanie w udostępnionej zmiennej, która zawiera wystąpienie tego typu, musi być chronione przez blokadę w celu zagwarantowania bezpieczeństwa wątków.

Zobacz też