المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to decide whether a class is "internal" by .net reflection ?



C# Programming
11-29-2009, 01:30 PM
We use reflection to get properties of a type. Here is a class :

namespace Test
{
internal class MyClass
{
public MyClass(){}
}

class MyTest
{
public static int Main(string[] args)
{
Assembly asm = Assembly.GetExecutingAssembly();
Type[] types = asm.GetTypes();
foreach(Type type in types)
Console.WriteLine(String.Concat(type.Name,":\t",type.IsPublic);
}

}

}
"MyClass" is a "intenal" class. However, there seems no property for decide this in Type Class.
Type.IsPublic, Type.IsNestedAssembly ... all these properties seems not work.

Is there any method to take care of this ?

Thanks.