本文介绍了如何获得大会的命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个程序集(类库的DLL),我已加载使用下面的code,

Consider i have an assembly(class library dll) which i have loaded using the following code,

Assembly a = Assembly.LoadFrom(@"C:\Documents and Settings\E454935\My Documents\Visual Studio 2005\Projects\nunit_dll_hutt\for_hutt_proj\bin\Debug\asdf.dll");

和我需要得到大会的类型。为了获得在键入我需要的组件的命名空间。

and i need to get the type of the Assembly. In order to get the type i need the namespace of the assembly.

Type t = asm.GetType("NAMESPACE.CLASSNAME",false,true);

我怎样才能在命名空间在上面行?!为序,以获得命名空间,我需要获得类型..?

how can i get the Namespace in the above line.?! as inorder to get the Namespace, i need to get the type..?

Type.Namespace;

也就是我需要得到可用于获取其类型的程序集的命名空间。

i.e i need to get the Namespace of the assembly which can be used to get its Type.

在此先感谢

推荐答案

使用Assembly.GetTypes() - 这将让你的所有类型的集合,然后你可以得到Namespace属性为每个

Use Assembly.GetTypes() - this will get you a collection of all types and then you can get the Namespace property for each of them.

那么我想你可以简单地检查所有的类型有相同的命名空间值,并使用该值。否则添加一些其他的逻辑来检测一下命名空间的考虑主要的。

Then I guess you can simply check that all the types have same Namespace value and use this value. Otherwise add some other logic to detect what namespace to consider primary.

这篇关于如何获得大会的命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 21:07