c# - Linq to Compare 2 Objects -


i have 2 objects.

public class globalsettings {     public bool { get; set; }     public bool b { get; set; }     public bool c { get; set; }     public bool d { get; set; } }  public class usersettings {     public bool { get; set; }     public bool b { get; set; }     public bool c { get; set; }     public bool d { get; set; } } 

i need compare these 2 objects. depend on property values of globalsettings need remove property usersettings.

for eg.

from globalsettings property a value false means want remove property usersettings. need remove propery a usersettings below.

public class usersettings {     public bool b { get; set; }     public bool c { get; set; }     public bool d { get; set; } } 

is possible linq?

if wanted automate using linq , reflection - e.g.

  var query = aprop in a.gettype().getproperties()               let avalue = aprop.getvalue(a)               let bprop = b.gettype().getproperty(aprop.name)               let bvalue = bprop.getvalue(b)               !avalue.equals(bvalue)               select new { aprop.name, avalue, bvalue };    var allthesame = !query.any(); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -