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();
Using Python's import numpy, the unique elements in the array are also obtained. In the first step convert the list to x=numpy. array(list) and then use numpy. unique(x) function to get the unique values from the list.
C# Linq Distinct() method removes the duplicate elements from a sequence (list) and returns the distinct elements from a single data source. It comes under the Set operators' category in LINQ query operators, and the method works the same way as the DISTINCT directive in Structured Query Language (SQL).
distinct in Linq to get result based on one field of the table (so do not require a whole duplicated records from table). I know writing basic query using distinct as followed: var query = (from r in table1 orderby r. Text select r).
Returns a list that contains all the values in list list with duplicates removed.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With