List<string> result = new List<string>();
存储了一些字符串 我想把相同的字符串只保留一个,其余的去掉

解决方案 »

  1.   

    先sort,然后遍历。。这是笨方法~~~坐看其他答案
      

  2.   

    http://www.google.cn/search?q=linq+Distinct&rls=com.microsoft:*:IE-SearchBox&ie=UTF-8&oe=UTF-8&sourceid=ie7&rlz=1I7GGLL_zh-CN
      

  3.   


     List<string> result = new List<string>();
                result.Add("2");
                result.Add("3");
                result.Add("1");
                result.Add("2");
                result.Add("5");          result=result.Union(result).ToList<string>();
              foreach (string s in result)
              {
                  Response.Write(s+"<br/>");
              }