I have the following classes and I am trying to call Compare method from ExportFileBaseBL class but I get the error
Cannot implicitly convert type 'Class1' to 'T'. An explicit conversion exists (are you missing a cast?)
public abstract class Class1<T> where T: Class2
{
public abstract Class1<T> Compare(Class1<T> otherObj);
}
public abstract class Class3<T, U> where T: Class1<U>
where U: Class2
{
public T Compare(T obj1, T obj2)
{
if (obj1.Prop1 > obj2.Prop1)
{
return obj1.Compare(obj2); // Compiler Error here
}
else
{
return obj2.Compare(obj1); // Compiler Error here
}
}
}
Shouldn't the type conversion be implicit? Am I missing something?