我有以下带有或多或少随机字符串的字符串列表:
List<string> list= new List<string>();
list.Add( "Apple" );
list.Add( "Bubble" );
list.Add( "Dino" );
list.Add( "Common" );
list.Sort();
list.Add( "Aalborg" );
list.Sort();
StringBuilder sb = new StringBuilder();
foreach ( string s in list) {
sb.Append( s + " -> ");
}
MessageBox.Show( sb.ToString() );
我明白了
Apple -> Bubble -> Common -> Dino -> Aalborg ->
代替
Aalborg -> Apple -> Bubble -> Common -> Dino ->
正如我所料
解决方案:
list.Sort(StringComparer.InvariantCultureIgnoreCase);
由于文化信息,Aa 被读取为 Å