Use standard numeric format specifiers.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
float value = 12345.12345F;
string specifier;
CultureInfo culture;
specifier = "G";
culture = CultureInfo.CreateSpecificCulture("eu-ES");
Console.WriteLine(value.ToString(specifier, culture));
Console.WriteLine(value.ToString(specifier, CultureInfo.InvariantCulture));
}
}
//12345,12
//12345.12
Related examples in the same category