Decimal separation sign for numbers

  • Thread starter Thread starter Patrick De Ridder
  • Start date Start date
P

Patrick De Ridder

Is there a way to change the system setting for
the decimal separation sign for numbers to "."
from within an application? If there, is could
you *please* give me the complete code?

Many thanks,
best wishes for the New Year
Patrick.
 
Let me reformulate my query. It is the decimal
separator for currency values I am looking
for to change from within an application.
 
Hi Patrick,

One quick way to do this is to transfer the number into a culture view
that uses periods instead of commas as does the US.

//since this uses monetary notation in front of the text it might not
be appropriate
int k = 12345;
CultureInfo dk = new CultureInfo("da-DK"); //us --> en-US
string w = k.ToString("c", dk);
Console.WriteLine (w);

you could also use the following code to do what you'd like...

using System;
using System.Globalization;

namespace test1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
int i = int.Parse("123456789");
NumberFormatInfo nfi = new CultureInfo( "en-US", false
).NumberFormat;
nfi.NumberGroupSeparator = "."; //changes from the default of
commas to periods
Console.WriteLine(i.ToString("N", nfi));
}
}
}

~~~~~~~~~~~~~
Tommie Carter
tcarternyc(at)hotmail(dot)com
 
Back
Top