参考MSDN:下面的代码示例演示如何使用 Dictionary<(Of <(TKey, TValue>)>)(IEqualityComparer<(Of <(TKey>)>)) 构造函数,利用来自另一个字典的已排序内容初始化 Dictionary<(Of <(TKey, TValue>)>)。该代码示例创建一个 SortedDictionary<(Of <(TKey, TValue>)>) 并在其中随机填充数据,然后将 SortedDictionary<(Of <(TKey, TValue>)>) 传递给 Dictionary<(Of <(TKey, TValue>)>)(IEqualityComparer<(Of <(TKey>)>)) 构造函数,创建一个经过排序的 Dictionary<(Of <(TKey, TValue>)>)。如果需要生成一个某些时候是静态的排序字典,这将十分有用;将数据从 SortedDictionary<(Of <(TKey, TValue>)>) 复制到 Dictionary<(Of <(TKey, TValue>)>) 可提高检索速度。
 
using System;
using System.Collections.Generic;public class Example
{
    public static void Main()
    {
        // Create a new sorted dictionary of strings, with string 
        // keys.
        SortedDictionary<string, string> openWith = 
            new SortedDictionary<string, string>();        // Add some elements to the dictionary. 
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("dib", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");        // Create a Dictionary of strings with string keys, and 
        // initialize it with the contents of the sorted dictionary.
        Dictionary<string, string> copy = 
            new Dictionary<string, string>(openWith);        // List the contents of the copy.
        Console.WriteLine();
        foreach( KeyValuePair<string, string> kvp in copy )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
               kvp.Key, kvp.Value);
        }
    }
}/* This code example produces the following output:Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = rtf, Value = wordpad.exe
Key = txt, Value = notepad.exe
 */
 

解决方案 »

  1.   

    楼上仁兄?SortedDisctionary有Min()方法?已经搞定:
    SortedList泛型可以使用index来获取。Another difference between the SortedDictionary and SortedList classes is that SortedList supports efficient indexed retrieval of keys and values through the collections returned by the Keys and Values properties. It is not necessary to regenerate the lists when the properties are accessed, because the lists are just wrappers for the internal arrays of keys and values. The following code shows the use of the Values property for indexed retrieval of values from a sorted list of strings:
      

  2.   

    sorry,夹层了。
    发现csdn这个论坛有点垃圾(用了一些自以为是的技术但是不适用)。。-_-!!!
    wxg:你的答复并没解决lz问题。
      

  3.   

    抱歉我的回复帮不到LZ
    但起码查了下,有点参考价值,
    对看贴的朋友也会有点帮助的不是吗?PS:与CSDN无关吧
      

  4.   

    http://msdn2.microsoft.com/zh-cn/library/bb909852.aspx
      

  5.   

    //未经过测试,自忖:
    应该不能吧,由于LZ要比较的是UserInfo类中的的某个属性,不遍历能比较出来??!!
      

  6.   

    可以排序的集合处理办法到处都是啊!!
    最简单的Array也有啊!!Array.Short();//