UInt16.MaxValue Champ

Définition

Représente la plus grande valeur possible de UInt16. Ce champ est constant.

public: System::UInt16 MaxValue = 65535;
public const ushort MaxValue = 65535;
val mutable MaxValue : uint16
Public Const MaxValue As UShort  = 65535

Valeur de champ

Value = 65535

Exemples

L’exemple suivant utilise les UInt16.MaxValue propriétés et UInt16.MinValue pour s’assurer qu’une Int32 valeur se trouve dans la plage du type avant de la UInt16 convertir en valeur UInt16 . Cela empêche l’opération de conversion de lever un OverflowException si la valeur entière n’est pas dans la plage du 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);
}
open System

let integerValue = 1216

if integerValue >= int UInt16.MinValue && integerValue <= int UInt16.MaxValue then
    let uIntegerValue = uint16 integerValue
    printfn $"{uIntegerValue}"
else
    printfn $"Unable to convert {integerValue} to a UInt16t."
Dim integerValue As Integer = 1216
Dim uIntegerValue As UShort

If integerValue >= UShort.MinValue And integerValue <= UShort.MaxValue Then
   uIntegerValue = CUShort(integerValue) 
   Console.WriteLine(uIntegerValue)
Else
   Console.WriteLine("Unable to convert {0} to a UInt16t.", integerValue)   
End If

Remarques

La valeur de cette constante est 65535 ; c’est-à-dire, 0xFFFF hexadécimaux.

S’applique à

Voir aussi