Struct byte
- Namespace
- System
- Assembly
- mscorlib.dll
Represents an 8-bit unsigned integer.
public byte
- Inherited Members
Fields
MaxValue
Represents the largest possible value of a Byte. This field is constant.
public const byte MaxValue = 255
Field Value
MinValue
Represents the smallest possible value of a Byte. This field is constant.
public const byte MinValue = 0
Field Value
Methods
Parse(string)
Converts the string representation of a number to its byte equivalent.
[CLSCompliant(false)]
public static byte Parse(string s)
Parameters
s
stringA string that contains a number to convert. The string is interpreted using the Integer style.
Returns
Exceptions
- ArgumentNullException
s
is null.- FormatException
s
is not of the correct format.
ToString()
Converts the value of the current Byte object to its equivalent string representation.
public override string ToString()
Returns
- 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.
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.
public string ToString(string format)
Parameters
format
stringA numeric format string.
Returns
- 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.
public static bool TryParse(string s, out byte result)
Parameters
s
stringA string that contains a number to convert.
result
byteWhen this method returns, contains the byte value equivalent to the number contained in
s
if the conversion succeeded, or zero if the conversion failed. This parameter is passed uninitialized; any value originally supplied inresult
will be overwritten.
Returns
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.