开发者

How to do language Specific sort in C#?

I have a generic list which can contain values in different languages based on current user's language preference. For example if user has selected Japanese, i will populate Japanese text in to the list.

I want to sort it based on Japanese text, not phonetic sort. We have a sort method with list or we can use a little extension method, that is fine. All I want to know is how do 开发者_Python百科i sort based on different language?

I checked out some documentation on MSDN about invariant culture etc. which did not help.


What you're looking for is documented here: http://msdn.microsoft.com/en-us/library/a7zyyk0c.aspx

Basically, you want to do the following:

 Thread.CurrentThread.CurrentCulture = new CultureInfo("ja-JP");

After that you use the normal "sort" methods (as defined in Array, List<T>, etc.) and they will obey the Japanese rules for string sorting.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜