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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -