Struct byte
Represents an 8-bit unsigned integer.
Inherited Members
Namespace: System
Assembly: mscorlib.dll
Syntax
public byte
Fields
MaxValue
Represents the largest possible value of a Byte. This field is constant.
Declaration
public const byte MaxValue = 255
Field Value
Type | Description |
---|---|
byte |
MinValue
Represents the smallest possible value of a Byte. This field is constant.
Declaration
public const byte MinValue = 0
Field Value
Type | Description |
---|---|
byte |
Methods
Parse(string)
Converts the string representation of a number to its byte equivalent.
Declaration
[CLSCompliant(false)]
public static byte Parse(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | A string that contains a number to convert. The string is interpreted using the Integer style. |
Returns
Type | Description |
---|---|
byte | A byte value that is equivalent to the number contained in |
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
FormatException |
|
ToString()
Converts the value of the current Byte object to its equivalent string representation.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the value of this object, which consists of a sequence of digits that range from 0 to 9 with no leading zeroes. |
Overrides
Remarks
The return value is formatted with the general numeric format specifier ("G") and the NumberFormatInfo object for the thread current culture.
ToString(string)
Converts the value of the current Byte object to its equivalent string representation using the specified format.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | A numeric format string. |
Returns
Type | Description |
---|---|
string | The string representation of the current Byte object, formatted as specified by the format parameter. |
TryParse(string, out byte)
Tries to convert the string representation of a number to its byte equivalent, and returns a value that indicates whether the conversion succeeded.
Declaration
public static bool TryParse(string s, out byte result)
Parameters
Type | Name | Description |
---|---|---|
string | s | A string that contains a number to convert. |
byte | result | When this method returns, contains the byte value equivalent to the number contained in |
Returns
Type | Description |
---|---|
bool | true if |
Remarks
The conversion fails and the method returns false if the s parameter is not in the correct format, if it is null or Empty, or if it represents a number less than MinValue or greater than MaxValue. The TryParse(string, out byte)(String, Byte) method is similar to the Byte.Parse(String) method, except that TryParse(string, out byte)(String, Byte) does not throw an exception if the conversion fails.