Table of Contents

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

byte

MinValue

Represents the smallest possible value of a Byte. This field is constant.

public const byte MinValue = 0

Field Value

byte

Methods

Parse(string)

Converts the string representation of a number to its byte equivalent.

[CLSCompliant(false)]
public static byte Parse(string s)

Parameters

s string

A string that contains a number to convert. The string is interpreted using the Integer style.

Returns

byte

A byte value that is equivalent to the number contained in s.

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 string

A 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 string

A string that contains a number to convert.

result byte

When 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 in result will be overwritten.

Returns

bool

true if s was converted successfully; otherwise, false.

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.