using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace Dic排序
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, int> dic = new Dictionary<string, int>();
dic.Add("q", );
dic.Add("d", );
dic.Add("f", );
dic.Add("g", );
dic.Add("l", );
dic.Add("h", );
//ascending升序
//descending降序
var dicSort = from objDic in dic orderby objDic.Value ascending select objDic; //int num = dicSort.Count();集合的个数
//int a = dicSort.ElementAt(0).Value;指定索引0的值
//也可以用for循环
foreach (KeyValuePair<string, int> kvp in dicSort)
{
Console.WriteLine(kvp.Key + ":" + kvp.Value);
} Console.ReadKey();
}
}