How to convert Arabic number to int?

前端 未结 6 2052
一向
一向 2020-12-05 14:26

I work on a project in C# which requires to use arabic numbers, but then it must store as integer in database, I need a solution to convert arabic numbers into int in C#. An

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-05 15:13

    Unfortunately it is not yet possible to parse the complete string representation by passing in an appropriate IFormatProvider(maybe in the upcoming versions). However, the char type has a GetNumericValue method which converts any numeric Unicode character to a double. For example:

    double two = char.GetNumericValue('٢');
    Console.WriteLine(two); // prints 2
    

    You could use it to convert one digit at a time.

提交回复
热议问题