📅  最后修改于: 2022-03-11 14:49:14.794000             🧑  作者: Mango
// The return of interface as an instance of that interface
// Ff the instance has a few instances then no need to worry about the type of instance
// This example returns an object that has implemented 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();
}