.net - C# : Check if two objects have same data -


assuming that Obj1 and Obj2 are objects of the same class And there are only fields in the square, is it possible to check whether there are data similar to two objects if the areas of the class are not known?

  var is samedata = false; PropertyInfo PROP () in Forex Currency (Obj1.GetType). GetProperties ()) {hasSameData = prop.GetValue (Obj1, blank) .Equals (prop.getveralu (obj2, null)); Break (ifasatata!); }  

It is based on perceptions (objects are of the same type), and it can possibly be re-applied so that it is more protective, but I keep it readable so that You can understand that in brief, use the reflection to repeat the fields, and check the values ​​of each until they are not satisfied that they do not match (there is no need to run again after them).


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -