0

To write the numbers in my motherhood language (Persian), I worked with the sting which its value is 1393 (The numbers are in Persian).

return Convert.ToInt32(Year);

But the following error appears:

Input string was not in correct format

I have tried both String and string

4
  • 3
    Showing us 1393 is not helping much, that will convert. Commented Jun 22, 2014 at 17:20
  • There's an overload for Convert.ToInt32() that lets you provide a specified culture as your IFormatProvider. Have you tried that? Commented Jun 22, 2014 at 17:22
  • @StriplingWarrior No, Do u have a reference link? Commented Jun 22, 2014 at 17:24
  • @Salman: msdn.microsoft.com/en-us/library/d7e175yd(v=vs.110).aspx It works in a similar way to Henk Holterman's answer. Commented Jun 22, 2014 at 17:49

1 Answer 1

4

This should work:

CultureInfo info = new CultureInfo("fa-Ir");
int x = Int32.Parse(inuptString, info);   // same as Convert.ToInt32()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.