Assembly.CreateInstance和Activator.CreateInstance之间的区别? [英] Difference between Assembly.CreateInstance and Activator.CreateInstance?

查看:454
本文介绍了Assembly.CreateInstance和Activator.CreateInstance之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是这些调用之间的区别?

What is the difference between these calls?

推荐答案

无。该Assembly.CreateInstance实际上引擎盖下调用Activator.CreateInstance。

None. The Assembly.CreateInstance actually calls Activator.CreateInstance under the hood.

在Assembly.CreateInstance使用反射器:

Using Reflector on Assembly.CreateInstance:

public object CreateInstance(string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes)
{
    Type type = this.GetType(typeName, false, ignoreCase);
    if (type == null)
    {
        return null;
    }
    return Activator.CreateInstance(type, bindingAttr, binder, args, culture, activationAttributes);
}

这篇关于Assembly.CreateInstance和Activator.CreateInstance之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆