摘要: 在上一篇中,实现了多态的例子,但是怎么实现按照要求创建相应的动物类呢?首先利用工厂模式(声明一个工厂类) class Factory { private string petType; public Factory() { } public Factory(string myType) { this.petType = myType; } public Animal CreateMyPet() { string assembly = "ClassLibrary1.";//注意这边要加一个点"." string className = assembly + petType; return (An 阅读全文
posted @ 2010-12-16 22:14 雁北飞 阅读(195) 评论(0) 推荐(0) 编辑
摘要: usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceConsoleApplication1{///summary///多态项目学习////summaryclassProgram{staticvoidMain(string[]args){AnimalmyPet1=newBird("Polly");myPet1.ShowType();AnimalmyPet2=newDog("Tom");myPet2.ShowType();AnimalmyPet3=newChicken( 阅读全文
posted @ 2010-12-16 22:13 雁北飞 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 1.使用FileUpload控件,在上传的使用saveUrl使用的是绝对路径而存入数据库的是相对路劲代码: if (!this.fileUpload1.HasFile || !this.fileUpload2.HasFile) { this.ShowMessage("您选择了企业会员注册,必须上传身份证和营业执照的信息", false); return; } else { string fileName1 = this.fileUpload1.FileName; string fileName2 = this.fileUpload2.FileName; string type1 = fileN 阅读全文
posted @ 2010-12-16 21:49 雁北飞 阅读(680) 评论(0) 推荐(0) 编辑