Type.GetType()

  • A+
所属分类:C#.Net教程
摘要

.net code private Type GetType(string className) { // Creates current domain. AppDomain currentDomain = AppDomain.CurrentDomain; // Makes an array for the list of assemblies. Assemb …

// .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;

}

weinxin
欢迎加入中国站长博客之家
本站的所有资源都会上传分享到博客之家,希望大家互相学习交流进步。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: