mscorlib(4.0.0.0) API with additions
System.Byte Struct Reference

Represents an 8-bit unsigned integer. More...

Inheritance diagram for System.Byte:
[legend]
Collaboration diagram for System.Byte:
[legend]

Public Member Functions

int CompareTo (object value)
 Compares this instance to a specified object and returns an indication of their relative values. More...
 
int CompareTo (byte value)
 Compares this instance to a specified 8-bit unsigned integer and returns an indication of their relative values. More...
 
override bool Equals (object obj)
 Returns a value indicating whether this instance is equal to a specified object. More...
 
bool Equals (byte obj)
 Returns a value indicating whether this instance and a specified T:System.Byte object represent the same value. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override string ToString ()
 Converts the value of the current T:System.Byte object to its equivalent string representation. More...
 
string ToString (string format)
 Converts the value of the current T:System.Byte object to its equivalent string representation using the specified format. More...
 
string ToString (IFormatProvider provider)
 Converts the numeric value of the current T:System.Byte object to its equivalent string representation using the specified culture-specific formatting information. More...
 
string ToString (string format, IFormatProvider provider)
 Converts the value of the current T:System.Byte object to its equivalent string representation using the specified format and culture-specific formatting information. More...
 
TypeCode GetTypeCode ()
 Returns the T:System.TypeCode for value type T:System.Byte. More...
 
bool IConvertible. ToBoolean (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToBoolean(System.IFormatProvider). More...
 
char IConvertible. ToChar (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToChar(System.IFormatProvider). More...
 
sbyte IConvertible. ToSByte (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToSByte(System.IFormatProvider). More...
 
byte IConvertible. ToByte (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToByte(System.IFormatProvider). More...
 
short IConvertible. ToInt16 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToInt16(System.IFormatProvider). More...
 
ushort IConvertible. ToUInt16 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToUInt16(System.IFormatProvider). More...
 
int IConvertible. ToInt32 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToInt32(System.IFormatProvider). More...
 
uint IConvertible. ToUInt32 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToUInt32(System.IFormatProvider). More...
 
long IConvertible. ToInt64 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToInt64(System.IFormatProvider). More...
 
ulong IConvertible. ToUInt64 (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToUInt64(System.IFormatProvider). More...
 
float IConvertible. ToSingle (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToSingle(System.IFormatProvider). More...
 
double IConvertible. ToDouble (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToDouble(System.IFormatProvider). More...
 
decimal IConvertible. ToDecimal (IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToDecimal(System.IFormatProvider). More...
 
DateTime IConvertible. ToDateTime (IFormatProvider provider)
 This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException. More...
 
object IConvertible. ToType (Type type, IFormatProvider provider)
 For a description of this member, see M:System.IConvertible.ToType(System.Type,System.IFormatProvider). More...
 
- Public Member Functions inherited from System.IEquatable< byte >
bool Equals (T other)
 Indicates whether the current object is equal to another object of the same type. More...
 

Static Public Member Functions

static byte Parse (string s)
 Converts the string representation of a number to its T:System.Byte equivalent. More...
 
static byte Parse (string s, NumberStyles style)
 Converts the string representation of a number in a specified style to its T:System.Byte equivalent. More...
 
static byte Parse (string s, IFormatProvider provider)
 Converts the string representation of a number in a specified culture-specific format to its T:System.Byte equivalent. More...
 
static byte Parse (string s, NumberStyles style, IFormatProvider provider)
 Converts the string representation of a number in a specified style and culture-specific format to its T:System.Byte equivalent. More...
 
static bool TryParse (string s, out byte result)
 Tries to convert the string representation of a number to its T:System.Byte equivalent, and returns a value that indicates whether the conversion succeeded. More...
 
static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out byte result)
 Converts the string representation of a number in a specified style and culture-specific format to its T:System.Byte equivalent. A return value indicates whether the conversion succeeded or failed. More...
 

Public Attributes

const byte MaxValue = 255
 Represents the largest possible value of a T:System.Byte. This field is constant. More...
 
const byte MinValue = 0
 Represents the smallest possible value of a T:System.Byte. This field is constant. More...
 

Detailed Description

Represents an 8-bit unsigned integer.

Definition at line 12 of file Byte.cs.

Member Function Documentation

◆ CompareTo() [1/2]

int System.Byte.CompareTo ( object  value)

Compares this instance to a specified object and returns an indication of their relative values.

Parameters
valueAn object to compare, or null.
Returns
A signed integer that indicates the relative order of this instance and value .Return Value Description Less than zero This instance is less than value . Zero This instance is equal to value . Greater than zero This instance is greater than value .-or- value is null.
Exceptions
T:System.ArgumentExceptionvalue is not a T:System.Byte.

Definition at line 30 of file Byte.cs.

◆ CompareTo() [2/2]

int System.Byte.CompareTo ( byte  value)

Compares this instance to a specified 8-bit unsigned integer and returns an indication of their relative values.

Parameters
valueAn 8-bit unsigned integer to compare.
Returns
A signed integer that indicates the relative order of this instance and value .Return Value Description Less than zero This instance is less than value . Zero This instance is equal to value . Greater than zero This instance is greater than value .

Definition at line 47 of file Byte.cs.

◆ Equals() [1/2]

override bool System.Byte.Equals ( object  obj)

Returns a value indicating whether this instance is equal to a specified object.

Parameters
objAn object to compare with this instance, or null.
Returns
true if obj is an instance of T:System.Byte and equals the value of this instance; otherwise, false.

Definition at line 57 of file Byte.cs.

◆ Equals() [2/2]

bool System.Byte.Equals ( byte  obj)

Returns a value indicating whether this instance and a specified T:System.Byte object represent the same value.

Parameters
objAn object to compare to this instance.
Returns
true if obj is equal to this instance; otherwise, false.

Definition at line 72 of file Byte.cs.

◆ GetHashCode()

override int System.Byte.GetHashCode ( )

Returns the hash code for this instance.

Returns
A hash code for the current T:System.Byte.

Definition at line 80 of file Byte.cs.

◆ GetTypeCode()

TypeCode System.Byte.GetTypeCode ( )

Returns the T:System.TypeCode for value type T:System.Byte.

Returns
The enumerated constant, F:System.TypeCode.Byte.

Implements System.IConvertible.

Definition at line 266 of file Byte.cs.

◆ Parse() [1/4]

static byte System.Byte.Parse ( string  s)
static

Converts the string representation of a number to its T:System.Byte equivalent.

Parameters
sA string that contains a number to convert. The string is interpreted using the F:System.Globalization.NumberStyles.Integer style.
Returns
A byte value that is equivalent to the number contained in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not of the correct format.
T:System.OverflowExceptions represents a number less than F:System.Byte.MinValue or greater than F:System.Byte.MaxValue.

Definition at line 95 of file Byte.cs.

◆ Parse() [2/4]

static byte System.Byte.Parse ( string  s,
NumberStyles  style 
)
static

Converts the string representation of a number in a specified style to its T:System.Byte equivalent.

Parameters
sA string that contains a number to convert. The string is interpreted using the style specified by style .
styleA bitwise combination of enumeration values that indicates the style elements that can be present in s . A typical value to specify is F:System.Globalization.NumberStyles.Integer.
Returns
A byte value that is equivalent to the number contained in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not of the correct format.
T:System.OverflowExceptions represents a number less than F:System.Byte.MinValue or greater than F:System.Byte.MaxValue. -or- s includes non-zero, fractional digits.
T:System.ArgumentExceptionstyle is not a T:System.Globalization.NumberStyles value. -or- style is not a combination of F:System.Globalization.NumberStyles.AllowHexSpecifier and F:System.Globalization.NumberStyles.HexNumber values.

Definition at line 115 of file Byte.cs.

◆ Parse() [3/4]

static byte System.Byte.Parse ( string  s,
IFormatProvider  provider 
)
static

Converts the string representation of a number in a specified culture-specific format to its T:System.Byte equivalent.

Parameters
sA string that contains a number to convert. The string is interpreted using the F:System.Globalization.NumberStyles.Integer style.
providerAn object that supplies culture-specific parsing information about s . If provider is null, the thread current culture is used.
Returns
A byte value that is equivalent to the number contained in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not of the correct format.
T:System.OverflowExceptions represents a number less than F:System.Byte.MinValue or greater than F:System.Byte.MaxValue.

Definition at line 132 of file Byte.cs.

◆ Parse() [4/4]

static byte System.Byte.Parse ( string  s,
NumberStyles  style,
IFormatProvider  provider 
)
static

Converts the string representation of a number in a specified style and culture-specific format to its T:System.Byte equivalent.

Parameters
sA string that contains a number to convert. The string is interpreted using the style specified by style .
styleA bitwise combination of enumeration values that indicates the style elements that can be present in s . A typical value to specify is F:System.Globalization.NumberStyles.Integer.
providerAn object that supplies culture-specific information about the format of s . If provider is null, the thread current culture is used.
Returns
A byte value that is equivalent to the number contained in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not of the correct format.
T:System.OverflowExceptions represents a number less than F:System.Byte.MinValue or greater than F:System.Byte.MaxValue. -or- s includes non-zero, fractional digits.
T:System.ArgumentExceptionstyle is not a T:System.Globalization.NumberStyles value. -or- style is not a combination of F:System.Globalization.NumberStyles.AllowHexSpecifier and F:System.Globalization.NumberStyles.HexNumber values.

Definition at line 153 of file Byte.cs.

◆ ToBoolean()

bool IConvertible. System.Byte.ToBoolean ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToBoolean(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
true if the value of the current instance is not zero; otherwise, false.

Implements System.IConvertible.

Definition at line 276 of file Byte.cs.

◆ ToByte()

byte IConvertible. System.Byte.ToByte ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToByte(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, unchanged.

Implements System.IConvertible.

Definition at line 303 of file Byte.cs.

◆ ToChar()

char IConvertible. System.Byte.ToChar ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToChar(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.Char.

Implements System.IConvertible.

Definition at line 285 of file Byte.cs.

◆ ToDateTime()

DateTime IConvertible. System.Byte.ToDateTime ( IFormatProvider  provider)

This conversion is not supported. Attempting to use this method throws an T:System.InvalidCastException.

Parameters
providerThis parameter is ignored.
Returns
This conversion is not supported. No value is returned.
Exceptions
T:System.InvalidCastExceptionIn all cases.

Implements System.IConvertible.

Definition at line 394 of file Byte.cs.

◆ ToDecimal()

decimal IConvertible. System.Byte.ToDecimal ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToDecimal(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.Decimal.

Implements System.IConvertible.

Definition at line 384 of file Byte.cs.

◆ ToDouble()

double IConvertible. System.Byte.ToDouble ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToDouble(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.Double.

Implements System.IConvertible.

Definition at line 375 of file Byte.cs.

◆ ToInt16()

short IConvertible. System.Byte.ToInt16 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToInt16(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to an T:System.Int16.

Implements System.IConvertible.

Definition at line 312 of file Byte.cs.

◆ ToInt32()

int IConvertible. System.Byte.ToInt32 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToInt32(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to an T:System.Int32.

Implements System.IConvertible.

Definition at line 330 of file Byte.cs.

◆ ToInt64()

long IConvertible. System.Byte.ToInt64 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToInt64(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to an T:System.Int64.

Implements System.IConvertible.

Definition at line 348 of file Byte.cs.

◆ ToSByte()

sbyte IConvertible. System.Byte.ToSByte ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToSByte(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to an T:System.SByte.

Implements System.IConvertible.

Definition at line 294 of file Byte.cs.

◆ ToSingle()

float IConvertible. System.Byte.ToSingle ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToSingle(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.Single.

Implements System.IConvertible.

Definition at line 366 of file Byte.cs.

◆ ToString() [1/4]

override string System.Byte.ToString ( )

Converts the value of the current T:System.Byte object to its equivalent string representation.

Returns
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.

Definition at line 224 of file Byte.cs.

◆ ToString() [2/4]

string System.Byte.ToString ( string  format)

Converts the value of the current T:System.Byte object to its equivalent string representation using the specified format.

Parameters
formatA numeric format string.
Returns
The string representation of the current T:System.Byte object, formatted as specified by the format parameter.
Exceptions
T:System.FormatExceptionformat includes an unsupported specifier. Supported format specifiers are listed in the Remarks section.

Definition at line 236 of file Byte.cs.

◆ ToString() [3/4]

string System.Byte.ToString ( IFormatProvider  provider)

Converts the numeric value of the current T:System.Byte object to its equivalent string representation using the specified culture-specific formatting information.

Parameters
providerAn object that supplies culture-specific formatting information.
Returns
The string representation of the value of this object in the format specified by the provider parameter.

Implements System.IConvertible.

Definition at line 246 of file Byte.cs.

◆ ToString() [4/4]

string System.Byte.ToString ( string  format,
IFormatProvider  provider 
)

Converts the value of the current T:System.Byte object to its equivalent string representation using the specified format and culture-specific formatting information.

Parameters
formatA standard or custom numeric format string.
providerAn object that supplies culture-specific formatting information.
Returns
The string representation of the current T:System.Byte object, formatted as specified by the format and provider parameters.
Exceptions
T:System.FormatExceptionformat includes an unsupported specifier. Supported format specifiers are listed in the Remarks section.

Implements System.IFormattable.

Definition at line 259 of file Byte.cs.

◆ ToType()

object IConvertible. System.Byte.ToType ( Type  type,
IFormatProvider  provider 
)

For a description of this member, see M:System.IConvertible.ToType(System.Type,System.IFormatProvider).

Parameters
typeThe type to which to convert this T:System.Byte value.
providerAn T:System.IFormatProvider implementation that supplies information about the format of the returned value.
Returns
The value of the current instance, converted to type .
Exceptions
T:System.ArgumentNullExceptiontype is null.
T:System.InvalidCastExceptionThe requested type conversion is not supported.

Implements System.IConvertible.

Definition at line 407 of file Byte.cs.

◆ ToUInt16()

ushort IConvertible. System.Byte.ToUInt16 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToUInt16(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.UInt16.

Implements System.IConvertible.

Definition at line 321 of file Byte.cs.

◆ ToUInt32()

uint IConvertible. System.Byte.ToUInt32 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToUInt32(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.UInt32.

Implements System.IConvertible.

Definition at line 339 of file Byte.cs.

◆ ToUInt64()

ulong IConvertible. System.Byte.ToUInt64 ( IFormatProvider  provider)

For a description of this member, see M:System.IConvertible.ToUInt64(System.IFormatProvider).

Parameters
providerThis parameter is ignored.
Returns
The value of the current instance, converted to a T:System.UInt64.

Implements System.IConvertible.

Definition at line 357 of file Byte.cs.

◆ TryParse() [1/2]

static bool System.Byte.TryParse ( string  s,
out byte  result 
)
static

Tries to convert the string representation of a number to its T:System.Byte equivalent, and returns a value that indicates whether the conversion succeeded.

Parameters
sA string that contains a number to convert. The string is interpreted using the F:System.Globalization.NumberStyles.Integer style.
resultWhen this method returns, contains the T:System.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
true if s was converted successfully; otherwise, false.

Definition at line 183 of file Byte.cs.

◆ TryParse() [2/2]

static bool System.Byte.TryParse ( string  s,
NumberStyles  style,
IFormatProvider  provider,
out byte  result 
)
static

Converts the string representation of a number in a specified style and culture-specific format to its T:System.Byte equivalent. A return value indicates whether the conversion succeeded or failed.

Parameters
sA string containing a number to convert. The string is interpreted using the style specified by style .
styleA bitwise combination of enumeration values that indicates the style elements that can be present in s . A typical value to specify is F:System.Globalization.NumberStyles.Integer.
providerAn object that supplies culture-specific formatting information about s . If provider is null, the thread current culture is used.
resultWhen this method returns, contains the 8-bit unsigned integer value equivalent to the number contained in s if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null or F:System.String.Empty, is not of the correct format, or represents a number less than F:System.Byte.MinValue or greater than F:System.Byte.MaxValue. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.
Returns
true if s was converted successfully; otherwise, false.
Exceptions
T:System.ArgumentExceptionstyle is not a T:System.Globalization.NumberStyles value. -or- style is not a combination of F:System.Globalization.NumberStyles.AllowHexSpecifier and F:System.Globalization.NumberStyles.HexNumber values.

Definition at line 199 of file Byte.cs.

Member Data Documentation

◆ MaxValue

const byte System.Byte.MaxValue = 255

Represents the largest possible value of a T:System.Byte. This field is constant.

Definition at line 18 of file Byte.cs.

◆ MinValue

const byte System.Byte.MinValue = 0

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

Definition at line 22 of file Byte.cs.


The documentation for this struct was generated from the following file: