I have 2 instances of the same objects, o1, and o2. If I am doing things like
if (o1.property1 != null) o1.property1 = o2.property1
for all the properties in the object. What would be the most efficient way to loop through all properties in an Object and do that? I saw people using PropertyInfo to check nulll of the properties but it seems like they could only get through the PropertyInfo collection but not link the operation of the properties.
Thanks.
Judging from your example i think your looking for something like this:
You can do this with reflection:
If you are going to use this many times, you could use a compiled expression for better performance:
And use it like this: