C# Convert ToSingle(Decimal)
Description
Convert ToSingle(Decimal)
converts the value of the
specified decimal number to an equivalent single-precision floating-point
number.
Syntax
Convert.ToSingle(Decimal)
has the following syntax.
public static float ToSingle(
decimal value
)
Parameters
Convert.ToSingle(Decimal)
has the following parameters.
value
- The decimal number to convert.
Returns
Convert.ToSingle(Decimal)
method returns A single-precision floating-point number that is equivalent to value.
value is rounded using rounding to nearest. For example, when rounded to
two decimals, the value 2.345 becomes 2.34 and the value 2.355 becomes 2.36.
Example
//from w ww . j ava 2s . c o m
using System;
public class MainClass{
public static void Main(String[] argv){
Console.WriteLine(Convert.ToSingle(123.123M));
}
}
The code above generates the following result.