Type thisType = typeof(B); ArrayList list = new ArrayList(); while (thisType.IsSubclassOf(typeof(object))) { list.AddRange(thisType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)); thisType = thisType.BaseType; } 只能这样了。。妈的
没看清楚,是这样的,private不能被继承。你可以不断循环找基类,这个代码使用了类似的方法: http://blog.sina.com.cn/s/blog_497dbcd10100f8px.htmlType type = request.GetType(); //获得请求的类型
while ((type != null) && (type.FullName != "System.Web.Hosting.ISAPIWorkerRequest")) { type = type.BaseType; }
动手能力稍强一些就找到了:Type t = typeof(B); var b = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();t = t.BaseType; var a = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();
ArrayList list = new ArrayList();
while (thisType.IsSubclassOf(typeof(object)))
{
list.AddRange(thisType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance));
thisType = thisType.BaseType;
}
只能这样了。。妈的
3L回答正确。
http://blog.sina.com.cn/s/blog_497dbcd10100f8px.htmlType type = request.GetType(); //获得请求的类型
while ((type != null) && (type.FullName != "System.Web.Hosting.ISAPIWorkerRequest"))
{
type = type.BaseType;
}
var b = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();t = t.BaseType;
var a = t.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).ToArray();