润宇betvictor85
业务介绍:betvictor xin1946betvictor85公司、betvictor85开发、betvictor85定制、betvictor85外包
betvictor85
方案
文章

betvictor85|betvictor xin1946|伟德国际 伟德官网

发布时间:2015/11/13  浏览次数:6次  字体【    】
C#2.0 (VS2005)实现方法:
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("2", "c Item");
dic.Add("6", "f Item");
dic.Add("1", "a Item");
dic.Add("7", "g Item");
dic.Add("3", "b Item");
dic.Add("5", "e Item");
dic.Add("4", "d Item");
List<KeyValuePair<string, string>> myList = new List<KeyValuePair<string, string>>(dic);
myList.Sort(delegate(KeyValuePair<string, string> s1, KeyValuePair<string, string> s2)
{
return s1.Value.CompareTo(s2.Value);
});
dic.Clear();
foreach (KeyValuePair<string, string> pair in myList)
{
dic.Add(pair.Key, pair.Value);
}
foreach (string key in dic.Keys)
{
Response.Write(dic[key] + "<br />");
}
C#3.0 Lambda表达式 (VS2008)的实现方法:

Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("2", "c Item");
dic.Add("6", "f Item");
dic.Add("1", "a Item");
dic.Add("7", "g Item");
dic.Add("3", "b Item");
dic.Add("5", "e Item");
dic.Add("4", "d Item");
var list = dic.OrderBy(s => s.Value);
foreach (var s in list)
{
Response.Write(s.Value + "<br />");
}
C#3.0 Linq (VS2008)的实现方法:
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("2", "c Item");
dic.Add("6", "f Item");
dic.Add("1", "a Item");
dic.Add("7", "g Item");
dic.Add("3", "b Item");
dic.Add("5", "e Item");
dic.Add("4", "d Item");
var dicSort = from d in dic
orderby d.Value
ascending
select d;
foreach (string key in dic.Keys)
{
Response.Write(dic[key] + "<br />");
}
 
西部IT网合作伙伴
合作伙伴
© 版权所有:betvictor xin1946润宇betvictor85科技有限公司 
公司地址:betvictor xin1946市碑林区 联系电话:029-87878512 手机:13468700578 联系人:李先生
Copyright ® 2009-2015 RunYusoft.com Inc. All Rights Reserved 
技术支持:betvictor xin1946润宇betvictor85科技有限公司  陕ICP备11000720号-3