Format float with Fixed-point format specifier f3 in CSharp

Description

The following code shows how to format float with Fixed-point format specifier f3.

Example


  //from w  w  w.j  a  v a 2s  . c om
  
  
     

using System;

class MainClass {

    public static void Main() {
        
        float myFloat = 1234.56789f;
        string myString8 = String.Format("{0, 10:f3}", myFloat);
        Console.WriteLine("String.Format(\"{0, 10:f3}\", myFloat) = " + myString8);
    
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var