public class Base { public string ID; private string name; public string Name { get { return name; } set { name = value; } } } public class Children : Base { } Type type = typeof(Children); FieldInfo[] field = type.GetFields(); foreach (FieldInfo f in field) Console.WriteLine(f.Name); PropertyInfo[] proper = type.GetProperties(); foreach (PropertyInfo p in proper) Console.WriteLine(p.Name); Console.ReadLine(); /* ID Name */
你确定FieldInfo[] field = type.GetFields();这句可以获取到ID和name?不可以吧
{
public string ID;
private string name; public string Name
{
get { return name; }
set { name = value; }
}
}
public class Children : Base
{
}
Type type = typeof(Children);
FieldInfo[] field = type.GetFields();
foreach (FieldInfo f in field)
Console.WriteLine(f.Name);
PropertyInfo[] proper = type.GetProperties();
foreach (PropertyInfo p in proper)
Console.WriteLine(p.Name);
Console.ReadLine();
/*
ID
Name
*/
你确定FieldInfo[] field = type.GetFields();这句可以获取到ID和name?不可以吧