Wednesday, October 7, 2009

Function to test whether 2 objects are equal or not.

public static bool AreEqual(object o1, object o2)
{
if (o1 == null && o2 == null)
{
return true;
}
if (o1 == null || o2 == null)
{
return false;
}
if (o1.GetType().FullName != o2.GetType().FullName)
{
return false;
}
return o1.Equals(o2);
}


//ofcourse Are not equal can be done just by negating the above function

public static bool AreNotEqual(object o1, object o2)
{
return !AreEqual(o1, o2);
}

No comments:

Node.JS rest api Tutorials