|
Dieser Artikel wurde manuell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen.
|
Übersetzung
Original
|
Convert.ToUInt16-Methode (Single)
.NET Framework 4
Assembly: mscorlib (in mscorlib.dll)
Parameter
- value
- Typ: System.Single
Die zu konvertierende Gleitkommazahl mit einfacher Genauigkeit.
Rückgabewert
Typ: System.UInt16| Ausnahme | Bedingung |
|---|---|
| OverflowException |
|
float[] numbers = { Single.MinValue, -1.38e10f, -1023.299f, -12.98f, 0f, 9.113e-16f, 103.919f, 17834.191f, Single.MaxValue }; ushort result; foreach (float 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: // -3.402823E+38 is outside the range of the UInt16 type. // -1.38E+10 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 Single value '0' to the UInt16 value 0. // Converted the Single value '9.113E-16' to the UInt16 value 0. // Converted the Single value '103.919' to the UInt16 value 104. // Converted the Single value '17834.19' to the UInt16 value 17834. // 3.402823E+38 is outside the range of the UInt16 type.
Windows 7, Windows Vista SP1 oder höher, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core wird nicht unterstützt), Windows Server 2008 R2 (Server Core wird mit SP1 oder höher unterstützt), Windows Server 2003 SP2
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.