C# Convert ToUInt16(Single)
Description
Convert ToUInt16(Single)
converts the value of the specified
single-precision floating-point number to an equivalent 16-bit unsigned
integer.
Syntax
Convert.ToUInt16(Single)
has the following syntax.
[CLSCompliantAttribute(false)]
public static ushort ToUInt16(
float value
)
Parameters
Convert.ToUInt16(Single)
has the following parameters.
value
- The single-precision floating-point number to convert.
Returns
Convert.ToUInt16(Single)
method returns value, rounded to the nearest 16-bit unsigned integer. If value is halfway
between two whole numbers, the even number is returned; that is, 4.5 is converted
to 4, and 5.5 is converted to 6.
Example
/*w w w. ja v a 2 s.com*/
using System;
public class MainClass{
public static void Main(String[] argv){
System.Console.WriteLine(Convert.ToUInt16((Single)123));
}
}
The code above generates the following result.