没有继承。
看下代码:
namespace 对象
{
class A
{
private string aa = "dfdf";
private string print()
{
return "****";
}
public string AA
{
get { return aa; }
}
}
class B : A
{
private int a = 1;
public void test()
{
//Type type = typeof(A);
//MethodInfo methodInfo = type.GetMethod("print", BindingFlags.NonPublic | BindingFlags.Instance);
//A testA = (A)Activator.CreateInstance(type, false);
//string str = (string)methodInfo.Invoke(testA, null);
//Console.WriteLine(str);
Type type2 = typeof(B);
MemberInfo[] memberInfo = type2.GetMembers(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);
foreach (MemberInfo mi in memberInfo)
{
Console.WriteLine(mi.Name);
}
}
class Program
{
static void Main(string[] args)
{
B b = new B();
b.test();
}
}
}
}
测试出来的结果是:没有父类的私有字段。ok。
|