.net3.5下利用Linq新特性对Dictionary进行快速排序
2009-08-01 17:10
483 查看
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace DictionarySorting
{
class Program
{
static void Main(string[] args)
{
Dictionary<int, int> dic = new Dictionary<int, int>();
dic.Add(1, 158);
dic.Add(5, 25);
dic.Add(3, 215);
dic.Add(2, 369);
dic.Add(4, 147);
var result = from pair in dic orderby pair.Value select pair;
foreach (KeyValuePair<int, int> pair in result)
{
Console.WriteLine("Key:{0}, Value:{1}", pair.Key, pair.Value);
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace DictionarySorting
{
class Program
{
static void Main(string[] args)
{
Dictionary<int, int> dic = new Dictionary<int, int>();
dic.Add(1, 158);
dic.Add(5, 25);
dic.Add(3, 215);
dic.Add(2, 369);
dic.Add(4, 147);
var result = from pair in dic orderby pair.Value select pair;
foreach (KeyValuePair<int, int> pair in result)
{
Console.WriteLine("Key:{0}, Value:{1}", pair.Key, pair.Value);
}
Console.ReadKey();
}
}
}
相关文章推荐
- 利用mysql对特殊字符和超长字符会进行截断的特性 进行存储型XSS攻击——WordPress <4.1.2 & <=4.2 存储型xss
- 利用WinCE6.0的新特性CellCore快速进行GSM驱动开发
- 利用特性(Attribute)对实体类进行验证
- 当DG进行failover之后重新恢复DG(利用rman 11gduplicate的ADG特性)
- 利用中位数进行快速排序
- 利用HTTP协议的特性进行拒绝服务攻击的一些构思
- 2008年8月小记(SQL2008FileStream特性,Linq-Aggregate,Linq-Dictionary,Linq-OfType, 数据库收缩,WCF-MSMQ,标题闪烁)
- 利用WinCE6.0的新特性CellCore快速进行GSM驱动开发
- 利用python特性进行提权
- [.NET] 如何利用 for loop 寻访 Dictionary (Linq)
- C# 中使用Linq 对Dictionary进行排序
- C# 中使用Linq 对Dictionary进行排序
- 2008年8月小记(SQL2008FileStream特性,Linq-Aggregate,Linq-Dictionary,Linq-OfType, 数据库收缩,WCF-MSMQ,标题闪烁)
- MVC3学习第十一章 葵花点穴手之隔空点穴----MVC3下利用EF和LINQ进行简单的多表联查、排序以及在Razor视图中调用自定义类
- 利用HTTP协议的特性进行拒绝服务攻击的一些构思
- 【javac添加python 列表特性11】利用修改后的javac实现快速排序
- asp.net 利用特性和正则表达式进行字段的验证(attribute)
- mvc中利用Attribute特性来进行进行简单的登陆验证
- 利用内存寻址进行快速排序的算法
- 数据库事务的四大特性、隔离级别以及Spring中如何利用AOP进行事务管理