UInt16.MaxValue Поле
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Представляет наибольшее возможное значение UInt16. Это поле является константой.
public: System::UInt16 MaxValue = 65535;
public const ushort MaxValue = 65535;
val mutable MaxValue : uint16
Public Const MaxValue As UShort = 65535
Значение поля
Value = 65535Примеры
В следующем примере используются UInt16.MaxValue свойства и UInt16.MinValue свойства, чтобы убедиться, что Int32 значение находится в диапазоне UInt16 типа перед преобразованием его в UInt16 значение. Это предотвращает вызов OverflowException операции преобразования, если целочисленное значение не находится в диапазоне UInt16 типа.
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
Комментарии
Значение этой константы равно 65535; то есть шестнадцатеричные 0xFFFF.