.NET List.Distinct [英] .NET List.Distinct
本文介绍了.NET List.Distinct的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用.NET 3.5。为什么我仍然会得到:
不包含一个定义独立的
本code:
使用System.Collections.Generic;
// ..。 。 。 。 code
名单<字符串>字=新的名单,其中,串>();
//许多字符串这里加入。 。 。
。字= Words.Distinct()了ToList();
解决方案
您
使用System.Linq的;
分明
是 System.Linq.Enumerable
定义,所以你需要添加using语句的扩展方法。
和别忘了添加引用 System.Core.dll的
(如果你使用VS2008,这已经为你做了)。
I'm using .NET 3.5. Why am I still be getting:
does not contain a definition for 'Distinct'
with this code:
using System.Collections.Generic;
//.. . . . . code
List<string> Words = new List<string>();
// many strings added here . . .
Words = Words.Distinct().ToList();
解决方案
Are you
using System.Linq;
?
Distinct
is an extension method defined in System.Linq.Enumerable
so you need to add that using statement.
And don't forget to add a reference to System.Core.dll
(if you're using VS2008, this has already been done for you).
这篇关于.NET List.Distinct的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文