开发者

How can i convert my string with my common language to English?

I have some Excel data including an Excel column I created programatically in sql table my excel column on the other hand. One of the column's name's is mydetail. When I try开发者_开发技巧 to convert it to uppercase I get MYDETAİL. How do I use the ToUpper() method to obtain MYDETAIL not MYDETAİL?


I'm guessing that you are Turkish, or at least using a Turkish computer.

In Turkish the "i" does convert to "İ" in upper case.

You need to use a different culture when doing the conversion by using String.ToUpper method that takes an CultureInfo object as an argument. If you use en-US or en-GB you should get what you want.

In fact the example on the page I linked to uses en-US and tr-TR (Turkey-Turkish) on the word "indigo" as an example of the differences.


Try something like:

String result = source.ToUpper(CultureInfo.InvariantCulture);

From MSDN:

use the InvariantCulture to ensure that the behavior will be consistent regardless of the culture settings of the system


You will need to call .ToUpper() with the desired CultureInfo. See MSDN with some examples on how to use .ToUpper(CultureInfo).


It is recommended to specify CultureInfo on all String manipulation methods like String.Format(), <primitive>.ToString() or for example Convert.Int32(object, CultureInfo).

FxCop does a good job in reminding you on issues with this in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜