如何根据每个单词的首字母进行排序
例如 排序前输出:while if for break switch
排序后输出:break for if switch while
给个思路,
[解决办法]
- C# code
SortedList mySortedList = new SortedList(); //while if for break switch mySortedList["while"] = "while"; mySortedList["if"] = "if"; mySortedList["for"] = "for"; mySortedList["break"] = "break"; mySortedList["switch"] = "switch"; if (!IsPostBack) { string s=string.Empty; foreach (DictionaryEntry Item in mySortedList) { s += Item.Value.ToString()+" "; } Response.Write(s); }