Converts float to string using the specified culture-specific format information. : float format « Data Types « C# / C Sharp






Converts float to string using the specified culture-specific format information.

 
using System;
using System.Globalization;

public class Example
{
    public static void Main()
    {

        float value;
        
        value = -16325.62015F;
        
        Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
        Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("de-DE")));
        
        value = 1234567.123E21F;
        Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("en-GB")));
        Console.WriteLine(value.ToString(CultureInfo.CreateSpecificCulture("de-DE")));
   }
}
/*
-16325.62
-16325.62
-16325,62
1.234567E+27
1.234567E+27
1,234567E+27
*/

   
  








Related examples in the same category

1.Converts float to string using the specified format.
2.Converts float to string using the specified format and culture-specific format information.
3.Format float value to currency
4.Format float value to exponential form
5.Format float value: F
6.Format value: N
7.Format float value: P
8.Converts float to to string with ToString method
9.Use standard numeric format specifiers.