c# - Generic class parameter not valid for Method? -
this question has answer here:
i've defined generic type following:
public class relevancegroup<t> { public string name; public list<relevance<t>> relevances { get; set; } = new list<relevance<t>> { }; public relevancegroup(string name) { this.name = name; } public relevancegroup(list<relevance<t>> relevances, string name) { this.name = name; this.relevances = relevances; } public bool changeshasbeenmade(list<relevance<t>> newrelevances) { return !(newrelevances.all(o => this.relevances.any(w => w.itemid == o.itemid)) && (this.relevances.all(o => newrelevances.any(w => w.itemid == o.itemid)))); }
my question regarding last method:
i compile error message in linq expression saying "operator == cannot applied operands of type t , t". have foreach loop make work. can make method work linq expression?
thanks in advance.
if t
reference type can add constraint , let compare ==
.
public class relevancegroup<t> t:class
Comments
Post a Comment