Byte Struct
SystemSummary
Represents an 8-bit unsigned integer. The range of values that can be stored in this type is from 0 to 255. This is a value type.
Syntax
public struct Byte : IComparable, ICloneable, IConvertible, IFormattable, IEquatable<byte>
Remarks
The Byte
structure represents an integer that is 8 bits wide. This means it can hold values from 0 to 255. It is a primitive type in C# and is widely used for representing raw data, such as byte arrays, or for low-level operations.
Byte
is a value type, meaning that variables of type Byte
store their data directly. This contrasts with reference types, which store a reference to the object's data.
The Byte
structure implements several interfaces, including:
IComparable
: Allows for comparison betweenByte
values.ICloneable
: Supports cloning.IConvertible
: Provides methods for converting aByte
value to other data types.IFormattable
: Enables custom formatting of theByte
value.IEquatable<byte>
: Allows for equality comparison with anotherByte
value.
When you perform arithmetic operations on Byte
values, the results are typically promoted to a larger integral type (like int
) to prevent overflow. You may need to explicitly cast the result back to byte
if you intend to store it in a byte
variable.
Members
Name | Type | Description |
---|---|---|
ToString() | Method | Returns the string representation of the current value. |
CompareTo(Object) | Method | Compares the current instance with another object of the same type or of a compatible type. |
Equals(Object) | Method | Determines whether the specified object is equal to the current object. |
GetHashCode() | Method | Returns the hash code for the current instance. |
GetTypeCode() | Method | Returns the TypeCode for the value type. |
MaxValue | Field | Represents the maximum value of a 8-bit unsigned integer, which is 255. |
MinValue | Field | Represents the minimum value of a 8-bit unsigned integer, which is 0. |
Parse(String) | Method | Converts the string representation of a number to its 8-bit unsigned integer equivalent. |
TryParse(String, out Byte) | Method | Converts the string representation of a number to its 8-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed. |
CompareTo(Byte) | Method | Compares the current instance with another Byte value. |
Equals(Byte) | Method | Determines whether the current instance is equal to another Byte value. |
ToString(IFormatProvider) | Method | Converts the current value to its equivalent string representation using the specified culture-specific format information. |
ToString(String) | Method | Converts the current value to its equivalent string representation using the specified format. |
ToString(String, IFormatProvider) | Method | Converts the current value to its equivalent string representation using the specified format and culture-specific format information. |
ToByte(IFormatProvider) | Method | Converts the current instance to a Byte . |
ToChar(IFormatProvider) | Method | Converts the current instance to a Char . |
ToDouble(IFormatProvider) | Method | Converts the current instance to a Double . |
ToInt16(IFormatProvider) | Method | Converts the current instance to a Int16 . |
ToInt32(IFormatProvider) | Method | Converts the current instance to a Int32 . |
ToInt64(IFormatProvider) | Method | Converts the current instance to a Int64 . |
ToSByte(IFormatProvider) | Method | Converts the current instance to a SByte . |
ToSingle(IFormatProvider) | Method | Converts the current instance to a Single . |
ToUInt16(IFormatProvider) | Method | Converts the current instance to a UInt16 . |
ToUInt32(IFormatProvider) | Method | Converts the current instance to a UInt32 . |
ToUInt64(IFormatProvider) | Method | Converts the current instance to a UInt64 . |
ToType(Type, IFormatProvider) | Method | Converts the value of this instance to specified type. |
Type Parameters
This type has no type parameters.
Attributes
The Byte
structure does not have any attributes directly applied to it.