How to Convert Persian Digits in variable to English Digits Using Culture?

后端 未结 15 2105
终归单人心
终归单人心 2021-02-02 07:10

I want to change persian numbers which are saved in variable like this :

string Value=\"۱۰۳۶۷۵۱\"; 

to

string Value=\"1036751\"         


        
15条回答
  •  北海茫月
    2021-02-02 07:27

    there is a simple way to do this

    public static string Fa2En(string str)
    {
      return str.Replace("۰", "0")
                .Replace("۱", "1")
                .Replace("۲", "2")
                .Replace("۳", "3")
                .Replace("۴", "4")
                .Replace("۵", "5")
                .Replace("۶", "6")
                .Replace("۷", "7")
                .Replace("۸", "8")
                .Replace("۹", "9");
    }
    

提交回复
热议问题