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

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

    You can manually convert them like so

        char[][] numbers = new char[][]
        {
            "0123456789".ToCharArray(),"persian numbers 0-9 here".ToCharArray()
        };
        public void Convert(string problem)
        {
            for (int x = 0; x <= 9; x++)
            {
                problem.Replace(numbers[0][x], numbers[1][x]);
            }
        }
    

    I don't know the persian numbers so you will have to add them into the char array.

提交回复
热议问题