Comparing 2 objects and retrive a list of fields with different values

Posted by ajj on Stack Overflow See other posts from Stack Overflow or by ajj
Published on 2010-06-17T09:26:54Z Indexed on 2010/06/17 9:43 UTC
Read the original article Hit count: 255

Filed under:
|

Hi given a class with 35 fields and 2 objects with a certain number of different fields value. is there an clever way to get a list with the fields name where the objext

Say obj1.Name = "aaa"; obj1.LastName = "bbb"; obj1.Address = "xcs";

obj2.Name = "aaa"; obj2.LastName = "ccc"; obj2.Address = "jk";

objective: list containing 2 strings LastName and Address

I see reflection as the way to go but with 35 fields I am afraid it s to heavy. Any other idea, like linq?

Thanks,

a.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ