|zyciis| 如何取各我的命名空间com下面的所有类,谢谢

zyciis215 2009-12-24 10:03:43
如我有
namespance com
{
public class MyInfo
{
}
public class YouInfo
{
}
}
----------
然后现在给出广本的com,要得出他里面和子级的所有类名,
开始我想用反射,但是我得不到com他不是类,只是个命名空间我没有办法实例化
System.Reflection.Assembly ass = System.Reflection.Assembly.(typeof(com));
说是命名空间不是类

谢谢
...全文
44 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lovely_baby 2009-12-24
  • 打赏
  • 举报
回复

[C#]
using System;
using System.Reflection;

class Mymemberinfo
{
public static int Main()
{
Console.WriteLine ("\nReflection.MemberInfo");

// Get the Type and MemberInfo.
Type MyType = Type.GetType("System.Empty");
MemberInfo[] Mymemberinfoarray = MyType.GetMembers();

// Get and display the DeclaringType method.
Console.Write("\nThere are {0} members in ",
Mymemberinfoarray.GetLength(0));
Console.Write("{0}.", MyType.FullName);

foreach (MemberInfo Mymemberinfo in Mymemberinfoarray)
{
Console.Write("\n" + Mymemberinfo.Name
+ " declaring type - " +
Mymemberinfo.DeclaringType);
}

return 0;
}
}

试试~~
满衣兄 2009-12-24
  • 打赏
  • 举报
回复
public class ClassName
{
public static string aaa
{
get {
return System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name;
}
}

}
满衣兄 2009-12-24
  • 打赏
  • 举报
回复
System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name;

62,263

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧