c# - Validate values of all properties in list with a duplicate for custom method -


i need write method can compare 2 lists see whether there differences between two, without specifying property in 2 lists compare. instance cannot say:

var exceptlist = list1.where (r => r.name !list2.any( r2.name == r.name ))

the bold part needs dynamic can re-use method different types of lists. know following example won't work, need similar:

var r = myleftlist.where(p => !myrighttlist.any(p2 =>       p2.gettype().getproperties().getvalue(myleftlist.indexof(p2)) ==       p.gettype().getproperties().getvalue(myrighttlist.indexof(p)))); 

you can use except extension method.

see msdn

being aware of point:

if want compare sequences of objects of custom data type, have implement iequalitycomparer generic interface in class.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -