I need to check the given instance is matching with the collection (Both are unknown types).
Have a look
void Main()
{
// Employee "John" Object got from Service Layer #1
Object obj1 = Client1.GetObject("John");
// Employee "John" Object got from Service Layer #2
Object obj2 = Client2.GetObject("John");
bool flag = CheckEquality(obj1, obj2); // Both objects are Unknown Type
}
The Equality Check Method:
public bool CheckEquality(object obj1, object obj2)
{
// Solution for Determining equality for unknown types
}
For example - consider the Following code: (Only for understanding purpose)
Scenario #1
public class EmpPerson
{
public int ID { get; set; }
public string Name { get; set; }
public string Address { get; set; }
}
obj1
holds the instance new EmpPerson() { ID = 1, Name = "John", Address = "Los Angeles" };
obj2
holds the instance new EmpPerson() { ID = 1, Name = "John", Address = "Los Angeles" };
Scenario #2
obj1
holds the value "John Smith"
.
obj2
holds the value "John Smith"
.
Scenario #3
obj1
holds the value "John Smith"
.
obj2
holds the instance new EmpPerson() { ID = 1, Name = "John", Address = "Los Angeles" };
Scenario #4
obj1
holds the value new UnknownTypeA()
.
obj2
holds the value new UnknownTypeX()
.
I need to Check both the objects are identical.
Kindly asssit me. how to check the equality for unknown types.