UInt16.MaxValue Campo
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Representa o maior valor possível de UInt16. Este campo é constante.
public: System::UInt16 MaxValue = 65535;
public const ushort MaxValue = 65535;
val mutable MaxValue : uint16
Public Const MaxValue As UShort = 65535
Valor de Campo
Value = 65535Exemplos
O exemplo seguinte utiliza as UInt16.MaxValue propriedades e UInt16.MinValue para garantir que um Int32 valor está no intervalo do UInt16 tipo antes de o converter para um UInt16 valor. Isto impede que a operação de conversão produza um OverflowException se o valor inteiro não estiver no intervalo do UInt16 tipo.
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
Observações
O valor desta constante é 65535; ou seja, 0xFFFF hexadecimal.