读书人

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

发布时间: 2012-04-17 15:06:33 作者: rapoo

如何根据每个单词的首字母进行排序
例如 排序前输出: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);        } 

读书人网 >asp.net

热点推荐