UInt16 Structure
 

Represents a 16-bit unsigned integer.

This API is not CLS-compliant.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Syntax
[SerializableAttribute]
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public struct UInt16 : IComparable, IFormattable, IConvertible, 
	IComparable<ushort>, IEquatable<ushort>
[SerializableAttribute]
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public value struct UInt16 : IComparable, IFormattable, IConvertible, 
	IComparable<unsigned short>, IEquatable<unsigned short>
[<Sealed>]
[<SerializableAttribute>]
[<CLSCompliantAttribute(false)>]
[<ComVisibleAttribute(true)>]
type UInt16 = 
    struct
        interface IComparable
        interface IFormattable
        interface IConvertible
        interface IComparable<uint16>
        interface IEquatable<uint16>
    end
<SerializableAttribute>
<CLSCompliantAttribute(False)>
<ComVisibleAttribute(True)>
Public Structure UInt16
	Implements IComparable, IFormattable, IConvertible, IComparable(OfUShort),
	IEquatable(OfUShort)
Methods
NameDescription
System_CAPS_pubmethod CompareTo

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

System_CAPS_pubmethod CompareTo

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

System_CAPS_pubmethod Equals

Returns a value indicating whether this instance is equal to a specified object.(Overrides ValueTypeEquals.)

System_CAPS_pubmethod Equals

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

System_CAPS_pubmethod GetHashCode

Returns the hash code for this instance.(Overrides ValueTypeGetHashCode.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod GetTypeCode

Returns the TypeCode for value type UInt16.

System_CAPS_pubmethod System_CAPS_static Parse

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

System_CAPS_pubmethod System_CAPS_static Parse

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

System_CAPS_pubmethod System_CAPS_static Parse

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

System_CAPS_pubmethod System_CAPS_static Parse

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

System_CAPS_pubmethod ToString

Converts the numeric value of this instance to its equivalent string representation.(Overrides ValueTypeToString.)

System_CAPS_pubmethod ToString

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

System_CAPS_pubmethod ToString

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

System_CAPS_pubmethod ToString

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

System_CAPS_pubmethod System_CAPS_static TryParse

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.

System_CAPS_pubmethod System_CAPS_static TryParse

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.

Fields
NameDescription
System_CAPS_pubfield System_CAPS_static MaxValue

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

System_CAPS_pubfield System_CAPS_static MinValue

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

Explicit Interface Implementations
NameDescription
System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToBoolean

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToBoolean.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToByte

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToByte.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToChar

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToChar.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToDateTime

This API supports the product infrastructure and is not intended to be used directly from your code. This conversion is not supported. Attempting to use this method throws an InvalidCastException.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToDecimal

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToDecimal.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToDouble

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToDouble.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToInt16

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToInt16.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToInt32

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToInt32.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToInt64

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToInt64.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToSByte

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToSByte.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToSingle

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToSingle.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToType

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToType.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToUInt16

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToUInt16.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToUInt32

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToUInt32.

System_CAPS_pubinterface System_CAPS_privmethod IConvertibleToUInt64

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IConvertibleToUInt64.

Remarks

The UInt16 value type represents unsigned integers with values ranging from 0 to 65535.

System_CAPS_importantImportant

   The UInt16 type is not CLS-compliant. The CLS-compliant alternative type is Int32. Int16 can be used instead to replace a UInt16 value that ranges from zero to Int16MaxValue. For more information about CLS compliance, see Language Independence and Language-Independent Components.

The UInt16 structure provides methods to compare instances of this type, convert the value of an instance to its string representation, and convert the string representation of a number to an instance of this type.

For information about how format specification codes control the string representation of value types, see Formatting Types in the .NET Framework.

Version Information
Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Thread Safety

All members of this type are thread safe. Members that appear to modify instance state actually return a new instance initialized with the new value. As with any other type, reading and writing to a shared variable that contains an instance of this type must be protected by a lock to guarantee thread safety.

Return to top