List<int> num = new List<int>() { 2, 9, 9, 2, 3, 9 };num.distinct();foreach (int item in num)
                {
                    for (int i = 0; i < num.Distinct().Count(); i++)
                    {
                        if (f.List.Cell(1, 1).Text.Length < sj.Distinct().Count())
                        {
                            f.List.Cell(1, 1).Text = f.List.Cell(1, 1).Text + sj[i].ToString();
                        }
                    }
                }
希望得到的结果是 239

解决方案 »

  1.   

    本帖最后由 caozhy 于 2012-08-20 21:54:17 编辑
      

  2.   


    num = num.Distinct(); 
          ~~~~~~~~~~~~~~~  这里报错
      

  3.   

    参考一下stackoverflow的答案:
    http://stackoverflow.com/questions/1851716/algorithm-to-find-the-duplicate-numbers-in-an-array-fastest-way
      

  4.   

    看了又看,LZ需要的是这个吧
    f.List.Cell(1, 1).Text = string.Join("", num.Distinct().ToArray());
      

  5.   

    NET  哪个版本???Distinct是NET3.5下   List<int> num = new List<int>() { 2, 9, 9, 2, 3, 9 };
       num.Distinct().OrderBy(n => n).ToList().ForEach(n => Console.WriteLine(n));
      

  6.   


          List<int> num = new List<int>() { 2, 9, 9, 2, 3, 9 };
          string str = string.Join("", num.Distinct().OrderBy(n => n).Select(n=>n.ToString()).ToArray());
          Console.WriteLine(str);