首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于:删除重复元素,错在哪呢

2012-09-08 
关于:剔除重复元素,错在哪呢?C# codeListint num new Listint() { 2, 9, 9, 2, 3, 9 }num.distinct

关于:剔除重复元素,错在哪呢?

C# code
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

[解决办法]
List<int> num = new List<int>() { 2, 9, 9, 2, 3, 9 };

num = num.Distinct().ToList();


[解决办法]
看了又看,LZ需要的是这个吧
C# code
f.List.Cell(1, 1).Text = string.Join("", num.Distinct().ToArray());
[解决办法]
探讨

引用:
C# code
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++)
……

NET 哪个版本???Dist……

热点排行