C# 2005,我在 Program.cs 中设置了如下文化:
CultureInfo myCulture = new CultureInfo("bn-IN");// like "en-US", "ja-JP" etc...
Thread.CurrentThread.CurrentCulture = myCulture;
Thread.CurrentThread.CurrentUICulture = myCulture;
Application.CurrentCulture = myCulture;
然后在打开应用程序后,我选择我的键盘,然后点击键盘 1,我的语言版本为 1。现在我想将它转换为整数,以便我可以执行加法、减法等。所以......
CultureInfo myCulture = Application.CurrentCulture;
myCulture.NumberFormat.DigitSubstitution = DigitShapes.NativeNational;
int i = Convert.ToInt32(textbox1.Text, myCulture.NumberFormat);// this line throws exception with message "Input string was not in a current format"
那么如何将另一种文化中的字符串(“en-US”除外)转换为整数?