Numeric format: {0:N}, {1:E} and G5 : Numeric format « Data Type « VB.Net Tutorial






Public Class Tester
    Public Shared Sub Main
        Dim intValue As Integer = 1234567
        Dim floatValue As Double = Math.PI
        Dim result As New System.Text.StringBuilder

        result.AppendLine(String.Format("{0}  ...  {1}", _
           intValue, floatValue))
        result.AppendLine(String.Format("{0:N}  ...  {1:E}", _
           intValue, floatValue))
        result.AppendLine(intValue.ToString("N5") & "  ...  " & _
           floatValue.ToString("G5"))

        Console.WriteLine(result.ToString())

 
    End Sub

End Class
1234567  ...  3.14159265358979
1,234,567.00  ...  3.141593E+000
1,234,567.00000  ...  3.1416








2.22.Numeric format
2.22.1.Numeric format: {0:N}, {1:E} and G5