Raghukatta
8 years agoContributor
FloatToStr in different counties for check points
Hi, I am working on desktop application which runs in different countries.I need to verify % values with a check points. For example if the value in US is 4.00% then in German it should be 4,00%...
- 8 years ago
Hi Raghukatta,
You can use the .NET String.Format method to format numbers according to the current locale:
dotNET.System.String.Format("{0:F2}%", 4).OleValue
This returns 4.00% on the US locale and 4,00% on the German locale. The format string {0:F2}% means "format the method's only argument (0:) as a floating-point number with 2 decimal digits (F2) and append % at the end."
If you run tests on one locale but need to format text for another locale, you can specify the locale as a parameter:
var number = 4; var culture = dotNET.System_Globalization.CultureInfo.zctor("de-de");
var str = dotNET.System.String.Format_3(culture, "{0:F2}%", number).OleValue;