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
{
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
num = num.Distinct();
~~~~~~~~~~~~~~~ 这里报错
http://stackoverflow.com/questions/1851716/algorithm-to-find-the-duplicate-numbers-in-an-array-fastest-way
f.List.Cell(1, 1).Text = string.Join("", num.Distinct().ToArray());
num.Distinct().OrderBy(n => n).ToList().ForEach(n => Console.WriteLine(n));
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);