|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
Convert.ToUInt16, méthode (Double)
.NET Framework 4.5
Cette API n'est pas conforme CLS. Espace de noms : System
Assembly : mscorlib (dans mscorlib.dll)
Paramètres
- value
- Type : System.Double
Nombre à virgule flottante double précision à convertir.
Valeur de retour
Type : System.UInt16| Exception | Condition |
|---|---|
| OverflowException |
double[] numbers = { Double.MinValue, -1.38e10, -1023.299, -12.98, 0, 9.113e-16, 103.919, 17834.191, Double.MaxValue }; ushort result; foreach (double number in numbers) { try { result = Convert.ToUInt16(number); Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", number.GetType().Name, number, result.GetType().Name, result); } catch (OverflowException) { Console.WriteLine("{0} is outside the range of the UInt16 type.", number); } } // The example displays the following output: // -1.79769313486232E+308 is outside the range of the UInt16 type. // -13800000000 is outside the range of the UInt16 type. // -1023.299 is outside the range of the UInt16 type. // -12.98 is outside the range of the UInt16 type. // Converted the Double value '0' to the UInt16 value 0. // Converted the Double value '9.113E-16' to the UInt16 value 0. // Converted the Double value '103.919' to the UInt16 value 104. // Converted the Double value '17834.191' to the UInt16 value 17834. // 1.79769313486232E+308 is outside the range of the UInt16 type.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.