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

后端 未结 15 2106
终归单人心
终归单人心 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:48

    The Saeed's Solution is Ok,But For Double Variables you Must Also replace "٫" Character To "." , So You Can Use :

    private string ToEnglishNumber(string strNum)
    {
    string[] pn = { "۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "٫" };
    string[] en = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9","." };
    string chash = strNum;
    for (int i = 0; i < 11; i++)
        chash = chash.Replace(pn[i], en[i]);
    return chash;
    }
    

提交回复
热议问题