当前位置: 代码迷 >> ASP.NET >> 怎么根据每个单词的首字母进行排序
  详细解决方案

怎么根据每个单词的首字母进行排序

热度:6499   发布时间:2013-02-25 00:00:00.0
如何根据每个单词的首字母进行排序
例如 排序前输出: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);        }
  相关解决方案