Mega Code Archive

 
Categories / VB.Net / Development
 

Convert ToSingle (Decimal) converts decimal number to single-precision floating-point number

Class Sample    Public Shared Sub Main()         Dim values() As Decimal = { Decimal.MinValue, -1034.23d, -12d, 0d, 147d, Decimal.MaxValue }         Dim result As Single                  For Each value As Decimal In values            result = Convert.ToSingle(value)            Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _                              value.GetType().Name, value, _                              result.GetType().Name, result)         Next                                       End Sub  End Class