object1本身就是一个对象(类的一个示例),何来object1的示例呢?如果是想类型转换的话,可以这样:string str="object1";
Object object1=(Object) str;或者你的确切的目的是?

解决方案 »

  1.   

    确切的目的是
    有n个方法
    public object function(string "object")
    {
      reuturn object
    }public xxx function(string "xxx")
    {
      reuturn xxx
    }public yyy function(string "yyy")
    {
      reuturn yyy
    }就是传入什么字符,反回和字符名一样的对象。
    谢谢
      

  2.   

    using System.Reflection;1、if you hadn't a reference to the assembly that include object1 class:Assembly assembly=Assembly.Load(/*your assembly that includes object1*/);
    Type type=assembly.CreateInstance("object1");
    type.InvokeMember(/*some method or attribute that defined in your assembly*/);2、else
    Type type=assembly.CreateInstance("object1");
    type.InvokeMember(/*some method or attribute that defined in your assembly*/);
    NOTICE:some code is not passed by compiler.To lookup MSDN for the section of System.Reflection would give you more help!
      

  3.   

    或者自己实现一个类似C++中的Template(不过估计难了点,~)
      

  4.   

    可以使用Activtor.CreateInstance或Assembly.CreateInstance创建。
      

  5.   

    我明白了楼主的意图是根据类型的名称动态生成实例的问题。这其实是.Net里的类型晚绑定技术,具体就参照 qimini(循序渐进)