62,046
社区成员
发帖
与我相关
我的任务
分享
namespace stu.yanzh //stu是我这个项目的DLL名,yanzh是这个文件夹的名
{
public class _2 : System.Web.UI.Page //本页面是2.aspx
{
private void Page_Load(object sender, System.EventArgs e)
{
double price=32.12,newprice;
xianjinfulei cs=null;
cs=factory.sellei();
newprice=cs.money(price);
}
}
//现金父类
abstract class xianjinfulei
{
public abstract double money(double price);
}
//打折类
class dazhe:xianjinfulei
{
public override double money(double pri)
{
return pri*0.2;
}
}
//价格的工厂,选择价格类
class factory
{
public static xianjinfulei sellei(string case1)
{
xianjinfulei cs=null;
System.Reflection.Assembly o =Assembly.Load("stu");
//为了简洁,省略判断在,直接反射打折类
cs=(xianjinfulei)o.CreateInstance("stu.yanzh.dazhe"); //这个地方就错了,提
示System.MissingMethodException: 未找到类型 stu.yanzh.dazhe 上的构造函数。stu.yanzh是命名空间
return cs;
}
}
}