假如已经有A B类 它们都实现了IC接口 则D称为工厂模式类: public static class D{ public static
已帮助 人
假如已经有A、B类,它们都实现了IC接口,则D称为工厂模式类: public static class D{ public static IC GetC(){ //Util是实用工具类,用于从配置文件获取k对应的字符串 Util.connString = ConfigurationManager.AppSettings["k"].ToString(); //取字串,用于判断 string x = Util.connString.Substring(1, 4); switch (x){ case "Astr": return new A(); //创建并返回A类对象 case "Bstr": return new B(); //创建并返回B类对象 default: return null; } } }

回答
共1条回复-
G 的 LL ( 1 )分析表中不含多重定义的条目
