Lesa á ensku Breyta

Deila með


UInt16.MinValue Field

Definition

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

public const ushort MinValue = 0;

Field Value

Value = 0

Examples

The following example uses the MinValue and MaxValue properties to ensure that an Int32 value is in the range of the UInt16 type before converting it to a UInt16 value. This prevents the conversion operation from throwing an OverflowException if the integer value is not in the range of the UInt16 type.

int integerValue = 1216; 
ushort uIntegerValue;

if (integerValue >= ushort.MinValue & integerValue <= ushort.MaxValue)
{
   uIntegerValue = (ushort) integerValue;
   Console.WriteLine(uIntegerValue);
} 
else
{
   Console.WriteLine("Unable to convert {0} to a UInt16t.", integerValue);
}

Remarks

The value of this constant is 0.

Applies to

See also