.NET Framework Class Library
UInt16 Structure

Represents a 16-bit unsigned integer.

This API is not CLS-compliant. The CLS-compliant alternative is Int32.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)
Syntax
<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_0%]> _
<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_1%](True)> _
<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_2%](False)> _
Public Structure UInt16 _
	Implements [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_3%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_4%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_5%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_6%](Of UShort),  _
	[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_0_0_7%](Of UShort)
[[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_0%]]
[[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_1%](true)]
[[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_2%](false)]
public struct UInt16 : [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_3%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_4%], 
	[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_5%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_6%]<ushort>, [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_1_0_7%]<ushort>
[[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_0%]]
[[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_1%](true)]
[[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_2%](false)]
public value class UInt16 : [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_3%], 
	[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_4%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_5%], [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_6%]<unsigned short>, [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_2_0_7%]<unsigned short>
[<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_1%]>]
[<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_2%](true)>]
[<[%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_3%](false)>]
type UInt16 =  
    struct 
        interface [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_4%] 
        interface [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_5%] 
        interface [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_6%] 
        interface [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_7%]<uint16>
        interface [%$TOPIC/s6eyk10z_en-us_VS_110_2_0_3_0_8%]<uint16>
    end

The UInt16 type exposes the following members.

Methods
  NameDescription
Public method Supported by the XNA Framework CompareTo(Object)Compares this instance to a specified object and returns an indication of their relative values.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps CompareTo(UInt16)Compares this instance to a specified 16-bit unsigned integer and returns an indication of their relative values.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps Equals(Object)Returns a value indicating whether this instance is equal to a specified object. (Overrides ValueTypeEquals(Object).)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps Equals(UInt16)Returns a value indicating whether this instance is equal to a specified UInt16 value.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetHashCodeReturns the hash code for this instance. (Overrides ValueTypeGetHashCode.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework GetTypeCodeReturns the TypeCode for value type UInt16.
Public method Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps Parse(String)Converts the string representation of a number to its 16-bit unsigned integer equivalent.
Public method Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps Parse(String, NumberStyles)Converts the string representation of a number in a specified style to its 16-bit unsigned integer equivalent.
Public method Static member Supported by Portable Class Library Supported in .NET for Windows Store apps Parse(String, IFormatProvider)Converts the string representation of a number in a specified culture-specific format to its 16-bit unsigned integer equivalent.
Public method Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps Parse(String, NumberStyles, IFormatProvider)Converts the string representation of a number in a specified style and culture-specific format to its 16-bit unsigned integer equivalent.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToStringConverts the numeric value of this instance to its equivalent string representation. (Overrides ValueTypeToString.)
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToString(IFormatProvider)Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToString(String)Converts the numeric value of this instance to its equivalent string representation using the specified format.
Public method Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps ToString(String, IFormatProvider)Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
Public method Static member Supported by Portable Class Library Supported in .NET for Windows Store apps TryParse(String, UInt16)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.
Public method Static member Supported by Portable Class Library Supported in .NET for Windows Store apps TryParse(String, NumberStyles, IFormatProvider, UInt16)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.
Top
Fields
  NameDescription
Public field Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps MaxValueRepresents the largest possible value of UInt16. This field is constant.
Public field Static member Supported by the XNA Framework Supported by Portable Class Library Supported in .NET for Windows Store apps MinValueRepresents the smallest possible value of UInt16. This field is constant.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method Supported by Portable Class Library Supported in .NET for Windows Store apps IComparableCompareToCompares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToBooleanInfrastructure. For a description of this member, see IConvertibleToBoolean.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToByteInfrastructure. For a description of this member, see IConvertibleToByte.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToCharInfrastructure. For a description of this member, see IConvertibleToChar.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToDateTimeInfrastructure. This conversion is not supported. Attempting to use this method throws an InvalidCastException.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToDecimalInfrastructure. For a description of this member, see IConvertibleToDecimal.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToDoubleInfrastructure. For a description of this member, see IConvertibleToDouble.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToInt16Infrastructure. For a description of this member, see IConvertibleToInt16.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToInt32Infrastructure. For a description of this member, see IConvertibleToInt32.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToInt64Infrastructure. For a description of this member, see IConvertibleToInt64.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToSByteInfrastructure. For a description of this member, see IConvertibleToSByte.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToSingleInfrastructure. For a description of this member, see IConvertibleToSingle.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToTypeInfrastructure. For a description of this member, see IConvertibleToType.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToUInt16Infrastructure. For a description of this member, see IConvertibleToUInt16.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToUInt32Infrastructure. For a description of this member, see IConvertibleToUInt32.
Explicit interface implemetation Private method Supported by the XNA Framework IConvertibleToUInt64Infrastructure. For a description of this member, see IConvertibleToUInt64.
Top
Remarks

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

Important noteImportant

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

Version Information

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1
Platforms

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

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.