Type.GetType()_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > Type.GetType()

Type.GetType()

 2011/8/10 17:21:40  huhu_long  http://vrplat.iteye.com  我要评论(0)
  • 摘要://.netcodeprivateTypeGetType(stringclassName){//Createscurrentdomain.AppDomaincurrentDomain=AppDomain.CurrentDomain;//Makesanarrayforthelistofassemblies.Assembly[]assems=currentDomain.GetAssemblies();Typetype=null;for(intj=0;j<assems.Length;j++)
  • 标签:
// .net code

private Type GetType(string className)
{
    // Creates current domain.
    AppDomain currentDomain = AppDomain.CurrentDomain;

    // Makes an array for the list of assemblies.
    Assembly[] assems = currentDomain.GetAssemblies();

    Type type = null;
    for (int j = 0; j < assems.Length; j++)
    {
        Type[] types = assems[j].GetTypes();
        for (int k = 0; k < types.Length; k++)
        {
            if (types[k].Name.Equals(className) || (types[k].FullName.Equals(className)))
            {
                type = types[k];
                break;
            }
        }
        if (type != null)
        {
            break;
        }
    }

    return type;
}
  • 相关文章
发表评论
用户名: 匿名