我正在学习Generics.当我有一个抽象方法模式时:
//Abstract Product
interface IPage
{
string pageType();
}
//Concerete Product 1
class ResumePage : IPage
{
public string pageType()
{
return "Resume Page";
}
}
//Concrete Product 2
class SummaryPage : IPage
{
public string pageType()
{
return "SummaryPage";
}
}
//Fcatory Creator
class FactoryCreator
{
public IPage CreateOnRequirement(int i)
{
if (i == 1) return new ResumePage();
else { return new SummaryPage(); }
}
}
//Client/Consumer
void Main()
{
FactoryCreator c = new FactoryCreator();
IPage p;
p = …
Run Code Online (Sandbox Code Playgroud)