java里的有一个Set的功能可以实现我的这个需求,不知道C#有没有类似的集合? 如果没有的话怎么可以实现这个功能呢?

解决方案 »

  1.   

    一个老外他自己对于c++ STL容器的c#的等同物的看法I generally use the following to replicate similar data structures from the STL.
    std::vector - List<T>
    std::list - LinkedList<T>
    std::map - Dictionary<Tkey, Tvalue>
    std::set - Dictionary<Tkey, Tvalue> (with null values)
    std::multimap - Dictionary<Tkey, List<Tvalue>>
    std::multiset - Dictionary<Tkey, int> (with int keeping count of the number of Tkeys) 
      

  2.   

    没有这个集合~~~~要自己写一个算法:
    算法思路如下:目标集合A
    1.定义一个源集合B,
    2.让后往B 中添加A 的元素
    需要判定
    foreach(string str in A)
    {
        if(B.Contains(str))
           continue;
        else 
          B.Add(str);
    }
    3.返回B ,就是自己所需的。
      

  3.   

    我所给的算法在2.0,3.0 框架中通用。当然在3.0 中可以使用linq来做更简单~~~