怎么样动态返回实体?
--------------------编程问答-------------------- 除非你的类都继承一个基类比如 A:B C:B
然后返回父类
public B Fa(){
swich(枚举)
case:1
return new A
case:2
return new B
} --------------------编程问答-------------------- 可以用字典来映射枚举和类名,然后用反射。 --------------------编程问答--------------------
比如呢? --------------------编程问答--------------------
Dictionary<string, string> openWith =
new Dictionary<string, string>();
// Add some elements to the dictionary. There are no
// duplicate keys, but some of the values are duplicates.
openWith.Add("txt", "notepad.exe");
openWith.Add("bmp", "paint.exe");
openWith.Add("dib", "paint.exe");
openWith.Add("rtf", "wordpad.exe");
像这样使用字典,自己吧string,string 传承enum,object就可以了
使用的时候可以是用openWith[你的枚举]然后做一次强转就可以了
传送门
补充:.NET技术 , ASP.NET