Yes, you can return an interface.
Let’s say classes A and B each implement interface Ic:
public interface Ic
{
int Type { get; }
string Name { get; }
}
public class A : Ic
{
.
.
.
}
public class B : Ic
.
.
.
}
public Ic func(bool flag)
{
if (flag)
return new A();
return new B();
}
In this example func is like factory method — it can return different objects!