c# – .NET List.Distinct
发布时间:2020-12-15 03:51:51 所属栏目:百科 来源:网络整理
导读:我正在使用.NET 3.5.为什么我还在得到: does not contain a definition for ‘Distinct’ 用这段代码: using System.Collections.Generic; //.. . . . . code Liststring Words = new Liststring(); // many strings added here . . . Words = Words.Disti
我正在使用.NET 3.5.为什么我还在得到:
用这段代码: using System.Collections.Generic; //.. . . . . code List<string> Words = new List<string>(); // many strings added here . . . Words = Words.Distinct().ToList(); 解决方法
你是
using System.Linq; ? Distinct是在System.Linq.Enumerable中定义的扩展方法,因此您需要添加该using语句. 并且不要忘记添加对System.Core.dll的引用(如果您使用的是VS2008,这已经为您完成了). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |