Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Custom number formatting in rigth to left languages

I am trying to write a number with a custom formatting in a right-to-left textbox(actually in a listview but whatever). here is the code:

NumberFormatInfo nfi = (NumberFormatInfo)
            CultureInfo.InvariantCulture.NumberFormat.Clone();
nfi.NumberGroupSeparator = " ";
textbox1.Text = (18700).ToString("#,###",nfi);

instead of 18 700 i get 700 18. can i fix this(get the required 18 700) without manipulating the string after number to string conversion?

like image 519
samad montazeri Avatar asked Jan 31 '26 14:01

samad montazeri


1 Answers

Instead of a space, use a no-break space. It's character is (char)0x00A0 or '\u00A0' in C#. You can also type it using keyboard using Alt+255.

So you can set NumberGroupSeparator this way:

nfi.NumberGroupSeparator = "\u00A0";
like image 147
Reza Aghaei Avatar answered Feb 02 '26 02:02

Reza Aghaei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!