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

Represents a 16-bit unsigned integer. More...

Inheritance diagram for System.UInt16:
[legend]
Collaboration diagram for System.UInt16:
[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 (ushort value)
 Compares this instance to a specified 16-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 (ushort obj)
 Returns a value indicating whether this instance is equal to a specified T:System.UInt16 value. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override string ToString ()
 Converts the numeric value of this instance to its equivalent string representation. More...
 
string ToString (IFormatProvider provider)
 Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. More...
 
string ToString (string format)
 Converts the numeric value of this instance to its equivalent string representation using the specified format. More...
 
string ToString (string format, IFormatProvider provider)
 Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information. More...
 
TypeCode GetTypeCode ()
 Returns the T:System.TypeCode for value type T:System.UInt16. 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< ushort >
bool Equals (T other)
 Indicates whether the current object is equal to another object of the same type. More...
 

Static Public Member Functions

static ushort Parse (string s)
 Converts the string representation of a number to its 16-bit unsigned integer equivalent. More...
 
static ushort Parse (string s, NumberStyles style)
 Converts the string representation of a number in a specified style to its 16-bit unsigned integer equivalent.This method is not CLS-compliant. The CLS-compliant alternative is M:System.Int32.Parse(System.String,System.Globalization.NumberStyles). More...
 
static ushort Parse (string s, IFormatProvider provider)
 Converts the string representation of a number in a specified culture-specific format to its 16-bit unsigned integer equivalent. More...
 
static ushort Parse (string s, NumberStyles style, IFormatProvider provider)
 Converts the string representation of a number in a specified style and culture-specific format to its 16-bit unsigned integer equivalent. More...
 
static bool TryParse (string s, out ushort result)
 Tries to convert the string representation of a number to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed. More...
 
static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out ushort result)
 Tries to convert the string representation of a number in a specified style and culture-specific format to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed. More...
 

Public Attributes

const ushort MaxValue = 65535
 Represents the largest possible value of T:System.UInt16. This field is constant. More...
 
const ushort MinValue = 0
 Represents the smallest possible value of T:System.UInt16. This field is constant. More...
 

Detailed Description

Represents a 16-bit unsigned integer.

Definition at line 13 of file UInt16.cs.

Member Function Documentation

◆ CompareTo() [1/2]

int System.UInt16.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 number indicating the relative values 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.UInt16.

Definition at line 31 of file UInt16.cs.

◆ CompareTo() [2/2]

int System.UInt16.CompareTo ( ushort  value)

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

Parameters
valueAn unsigned integer to compare.
Returns
A signed number indicating the relative values 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 48 of file UInt16.cs.

◆ Equals() [1/2]

override bool System.UInt16.Equals ( object  obj)

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

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

Definition at line 58 of file UInt16.cs.

◆ Equals() [2/2]

bool System.UInt16.Equals ( ushort  obj)

Returns a value indicating whether this instance is equal to a specified T:System.UInt16 value.

Parameters
objA 16-bit unsigned integer to compare to this instance.
Returns
true if obj has the same value as this instance; otherwise, false.

Definition at line 73 of file UInt16.cs.

◆ GetHashCode()

override int System.UInt16.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

Definition at line 81 of file UInt16.cs.

◆ GetTypeCode()

TypeCode System.UInt16.GetTypeCode ( )

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

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

Implements System.IConvertible.

Definition at line 272 of file UInt16.cs.

◆ Parse() [1/4]

static ushort System.UInt16.Parse ( string  s)
static

Converts the string representation of a number to its 16-bit unsigned integer equivalent.

Parameters
sA string that represents the number to convert.
Returns
A 16-bit unsigned integer equivalent to the number contained in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.UInt16.MinValue or greater than F:System.UInt16.MaxValue.

Definition at line 140 of file UInt16.cs.

◆ Parse() [2/4]

static ushort System.UInt16.Parse ( string  s,
NumberStyles  style 
)
static

Converts the string representation of a number in a specified style to its 16-bit unsigned integer equivalent.This method is not CLS-compliant. The CLS-compliant alternative is M:System.Int32.Parse(System.String,System.Globalization.NumberStyles).

Parameters
sA string that represents the number to convert. The string is interpreted by using the style specified by the style parameter.
styleA bitwise combination of the enumeration values that specify the permitted format of s . A typical value to specify is F:System.Globalization.NumberStyles.Integer.
Returns
A 16-bit unsigned integer equivalent to the number specified in s .
Exceptions
T:System.ArgumentNullExceptions is null.
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.
T:System.FormatExceptions is not in a format compliant with style .
T:System.OverflowExceptions represents a number less than F:System.UInt16.MinValue or greater than F:System.UInt16.MaxValue. -or- s includes non-zero, fractional digits.

Definition at line 161 of file UInt16.cs.

◆ Parse() [3/4]

static ushort System.UInt16.Parse ( string  s,
IFormatProvider  provider 
)
static

Converts the string representation of a number in a specified culture-specific format to its 16-bit unsigned integer equivalent.

Parameters
sA string that represents the number to convert.
providerAn object that supplies culture-specific formatting information about s .
Returns
A 16-bit unsigned integer equivalent to the number specified in s .
Exceptions
T:System.ArgumentNullExceptions is null.
T:System.FormatExceptions is not in the correct format.
T:System.OverflowExceptions represents a number less than F:System.UInt16.MinValue or greater than F:System.UInt16.MaxValue.

Definition at line 179 of file UInt16.cs.

◆ Parse() [4/4]

static ushort System.UInt16.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 16-bit unsigned integer equivalent.

Parameters
sA string that represents the number to convert. The string is interpreted by using the style specified by the style parameter.
styleA bitwise combination of enumeration values that indicate 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 .
Returns
A 16-bit unsigned integer equivalent to the number specified in s .
Exceptions
T:System.ArgumentNullExceptions is null.
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.
T:System.FormatExceptions is not in a format compliant with style .
T:System.OverflowExceptions represents a number that is less than F:System.UInt16.MinValue or greater than F:System.UInt16.MaxValue. -or- s includes non-zero, fractional digits.

Definition at line 201 of file UInt16.cs.

◆ ToBoolean()

bool IConvertible. System.UInt16.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 282 of file UInt16.cs.

◆ ToByte()

byte IConvertible. System.UInt16.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, converted to a T:System.Byte.

Implements System.IConvertible.

Definition at line 309 of file UInt16.cs.

◆ ToChar()

char IConvertible. System.UInt16.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 291 of file UInt16.cs.

◆ ToDateTime()

DateTime IConvertible. System.UInt16.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 400 of file UInt16.cs.

◆ ToDecimal()

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

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

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

Implements System.IConvertible.

Definition at line 390 of file UInt16.cs.

◆ ToDouble()

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

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

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

Implements System.IConvertible.

Definition at line 381 of file UInt16.cs.

◆ ToInt16()

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

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

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

Implements System.IConvertible.

Definition at line 318 of file UInt16.cs.

◆ ToInt32()

int IConvertible. System.UInt16.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 this instance, converted to an T:System.Int32.

Implements System.IConvertible.

Definition at line 336 of file UInt16.cs.

◆ ToInt64()

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

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

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

Implements System.IConvertible.

Definition at line 354 of file UInt16.cs.

◆ ToSByte()

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

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

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

Implements System.IConvertible.

Definition at line 300 of file UInt16.cs.

◆ ToSingle()

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

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

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

Implements System.IConvertible.

Definition at line 372 of file UInt16.cs.

◆ ToString() [1/4]

override string System.UInt16.ToString ( )

Converts the numeric value of this instance to its equivalent string representation.

Returns
The string representation of the value of this instance, which consists of a sequence of digits ranging from 0 to 9, without a sign or leading zeros.

Definition at line 90 of file UInt16.cs.

◆ ToString() [2/4]

string System.UInt16.ToString ( IFormatProvider  provider)

Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.

Parameters
providerAn object that supplies culture-specific formatting information.
Returns
The string representation of the value of this instance, which consists of a sequence of digits ranging from 0 to 9, without a sign or leading zeros.

Implements System.IConvertible.

Definition at line 100 of file UInt16.cs.

◆ ToString() [3/4]

string System.UInt16.ToString ( string  format)

Converts the numeric value of this instance to its equivalent string representation using the specified format.

Parameters
formatA numeric format string.
Returns
The string representation of the value of this instance as specified by format .
Exceptions
T:System.FormatExceptionThe format parameter is invalid.

Definition at line 111 of file UInt16.cs.

◆ ToString() [4/4]

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

Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.

Parameters
formatA numeric format string.
providerAn object that supplies culture-specific formatting information.
Returns
The string representation of the value of this instance, as specified by format and provider .
Exceptions
T:System.FormatExceptionformat is invalid.

Implements System.IFormattable.

Definition at line 124 of file UInt16.cs.

◆ ToType()

object IConvertible. System.UInt16.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.UInt16 value.
providerAn T:System.IFormatProvider implementation that supplies information about the format of the returned value.
Returns
The current value of this instance, converted to type .

Implements System.IConvertible.

Definition at line 410 of file UInt16.cs.

◆ ToUInt16()

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

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

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

Implements System.IConvertible.

Definition at line 327 of file UInt16.cs.

◆ ToUInt32()

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

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

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

Implements System.IConvertible.

Definition at line 345 of file UInt16.cs.

◆ ToUInt64()

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

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

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

Implements System.IConvertible.

Definition at line 363 of file UInt16.cs.

◆ TryParse() [1/2]

static bool System.UInt16.TryParse ( string  s,
out ushort  result 
)
static

Tries to convert the string representation of a number to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed.

Parameters
sA string that represents the number to convert.
resultWhen this method returns, contains the 16-bit unsigned integer value that is 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 in the correct format. , or represents a number less than F:System.UInt16.MinValue or greater than F:System.UInt16.MaxValue. 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 232 of file UInt16.cs.

◆ TryParse() [2/2]

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

Tries to convert the string representation of a number in a specified style and culture-specific format to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed.

Parameters
sA string that represents the number to convert. The string is interpreted by using the style specified by the style parameter.
styleA bitwise combination of enumeration values that indicates the permitted format of s . A typical value to specify is F:System.Globalization.NumberStyles.Integer.
providerAn object that supplies culture-specific formatting information about s .
resultWhen this method returns, contains the 16-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 in a format compliant with style , or represents a number less than F:System.UInt16.MinValue or greater than F:System.UInt16.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 249 of file UInt16.cs.

Member Data Documentation

◆ MaxValue

const ushort System.UInt16.MaxValue = 65535

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

Definition at line 19 of file UInt16.cs.

◆ MinValue

const ushort System.UInt16.MinValue = 0

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

Definition at line 23 of file UInt16.cs.


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