Force.NET to write your own Persian numbers instead of the US format

I tried to install ASP.NET Application Culture and UICulture without success. Also tried it in a C # Windows application.

System.Globalization.CultureInfo a = new System.Globalization.CultureInfo("fa-IR");
a.NumberFormat.DigitSubstitution = System.Globalization.DigitShapes.NativeNational;
string Q = string.Format(a, "{0}", 1234567890); // Output 1234567890 instead of ٠١٢٣٤٥٦٧٨٩

Is there any part that I missed in the code?

+5
source share
1 answer

There is no support in the C # /. Net structure for outputting numbers with digits other than 0-9 (or parsing support).

. ( / separtor/currency), 0-9 String.Replace , , String.Join.

 var converted = String.Join("", 123490.ToString().Select(c => "٠١٢٣٤٥٦٧٨٩"[c-'0']));
+3

All Articles