Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 强制.NET编写本地波斯语数字而不是US格式_C#_Asp.net_.net_Vb.net_Cultureinfo - Fatal编程技术网

C# 强制.NET编写本地波斯语数字而不是US格式

C# 强制.NET编写本地波斯语数字而不是US格式,c#,asp.net,.net,vb.net,cultureinfo,C#,Asp.net,.net,Vb.net,Cultureinfo,我尝试设置ASP.NET应用程序的区域性和UICulture,但没有成功。 也在C#Windows应用程序中尝试过 System.Globalization.CultureInfo a = new System.Globalization.CultureInfo("fa-IR"); a.NumberFormat.DigitSubstitution = System.Globalization.DigitShapes.NativeNational; string Q = string.Format

我尝试设置ASP.NET应用程序的区域性和UICulture,但没有成功。 也在C#Windows应用程序中尝试过

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 ٠١٢٣٤٥٦٧٨٩
代码中是否有我遗漏的部分?

在C#/.Net框架中不支持使用0-9以外的数字输出数字(也不支持解析)

您需要自己输出数字。您应该能够首先使用内置代码格式化数字(以获得正确的分组/十进制分隔符/货币),然后使用
字符串将0-9替换为国家数字。替换
或将数字映射到所需的字符,并使用
字符串将其联接。联接

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

如果您查看该属性的文档,您会发现它尚未被使用:DigitSubstitution属性保留供将来使用。当前,它未用于当前NumberFormatInfo对象的解析或格式化操作。相关:和