Unlike user comparison, calibration error is given

I have the following code:

IEqualityComparer<WorkItem> comparer = 
     new LambdaComparer<WorkItem>((item1, item2) => item1.Type == item2.Type);

var someVar = Pad.Distinct(comparer);

(The idea is to get 1 of each type)
And it gives the following error message:

The type arguments for method 'System.Linq.Enumerable.Distinct
(System.Collections.Generic.IEnumerable, 
System.Collections.Generic.IEqualityComparer) 'cannot be inferred 
from the usage. Try specifying the type arguments explicitly. 490

I did something similar and it works fine:

Pad = new Dictionary<WorkItem, Canvas>(new LambdaComparer<WorkItem>((x, y) => x.Id == y.Id, x => x.Id));

Therefore, I do not think this is my LamdaComparer class.

Any ideas on how to fix this? (I think I could just do ForEach and get the report manually).

+3
source share
1 answer

Pad Dictionary, IEqualityComparer<KeyValuePair<WorkItem, Canvas>>.

, , , Distinct, .: (

, , , , LambdaComparer . "" -.

+1

Source: https://habr.com/ru/post/1729608/


All Articles