Linked Questions

5 votes
3 answers
4k views

Possible Duplicate: Comparing object properties in c# Let's say I have a POCO: public class Person { public string Name { get; set; } public DateTime DateOfBirth { get; set; } public ...
Daniel T.'s user avatar
  • 38.6k
5 votes
4 answers
2k views

I have a database containing components with about 20 properties. To find out if an update is needed I want to check if all properties for the two objects, except DateCreated and Id, matches. If all ...
Petter Vennberg's user avatar
0 votes
1 answer
117 views

I have a generic function(object, object), one of parameters can be new() when I try to compare object to new() it is always false. public static void TestFunction<T>(object requestData, ...
Power Mouse's user avatar
  • 1,451
203 votes
13 answers
123k views

I have a block of code that serializes a type into a Html tag. Type t = typeof(T); // I pass <T> in as a paramter, where myObj is of type T tagBuilder.Attributes.Add("class", t.Name); foreach (...
DaveDev's user avatar
  • 42.4k
47 votes
15 answers
4k views

I have the following method: protected override bool ModifyExistingEntity(Product entity, ProductModel item) { bool isModified = false; if (entity.Title != item.Title) { ...
Sergey Metlov's user avatar
49 votes
10 answers
37k views

I came across this recently, up until now I have been happily overriding the equality operator (==) and/or Equals method in order to see if two references types actually contained the same data (i.e. ...
Rob Cooper's user avatar
  • 28.9k
59 votes
8 answers
33k views

The project I'm working on needs some simple audit logging for when a user changes their email, billing address, etc. The objects we're working with are coming from different sources, one a WCF ...
Pete Nelson's user avatar
  • 1,338
31 votes
7 answers
11k views

I have these data transfer objects: public class Report { public int Id { get; set; } public int ProjectId { get; set; } //and so on for many, many properties. } I don't want to write ...
MatthewMartin's user avatar
14 votes
6 answers
31k views

I have two classes Address and Employee as follows: public class Address { public string AddressLine1 { get; set; } public string AddressLine2 { get; set; } public string City { get; set;...
Kumar's user avatar
  • 2,863
13 votes
10 answers
15k views

Why it is not a good practice to compare two objects by serializing them and then compare the strings like in the following example? public class Obj { public int Prop1 { get; set; } public ...
meJustAndrew's user avatar
  • 6,759
16 votes
5 answers
16k views

I'm working on an mvc3 web app. When the user updates something, I want to compare the old data to the new one the user is inputing and for each field that is different add those to a log to create an ...
LanFeusT's user avatar
  • 2,442
12 votes
2 answers
8k views

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<String> with the fields name where the object are as following? e....
ajj's user avatar
  • 121
15 votes
5 answers
8k views

What is the algorithm used by the memberwise equality test in .NET structs? I would like to know this so that I can use it as the basis for my own algorithm. I am trying to write a recursive ...
Damian Powell's user avatar
8 votes
5 answers
17k views

I have a class it contains some string members, some double members and some array objects. I create two objects of this class, is there any simplest, efficient way of comparing these objects and ...
siva's user avatar
  • 1,265
5 votes
4 answers
4k views

I have a class with lots of properties. A shallow copy is enough to fully replicate the object. I need to compare an object just to check if it contains exactly the same values as another. My ideas: ...
maxp's user avatar
  • 25.2k

15 30 50 per page