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, object storedData) where T : class, new()
{
if (requestData != null && storedData != null)
if (requestData?.GetType().Name != storedData?.GetType().Name)
{ throw new Exception("object types are not match"); return; }
if (requestData == null) throw new Exception("request can not be null");
```
//storedData might be new T()
// but even i am creating new objects to compare inside function - no luck
```
object o = (T)Activator.CreateInstance(typeof(T));
object o1 = (T)Activator.CreateInstance(typeof(T));
object o2 = new T();
T test = new T();
```//all return false
o.Equals(o1).Dump();
test.Equals(new T()).Dump();
o2.Equals(o).Dump();
}
I expect the comparison to be true.