UInt16.MinValue Field
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents the smallest possible value of UInt16. This field is constant.
public: System::UInt16 MinValue = 0;
public const ushort MinValue = 0;
val mutable MinValue : uint16
Public Const MinValue As UShort = 0
Field Value
Value = 0Examples
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);
}
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
Remarks
The value of this constant is 0.
Applies to
See also
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για