C#中通过发射获取对象的所有属性出错, 求指导. 标红部分不能正确获取到language里面的属性值
首先定义了一个student类, 这个类中有有个成员speakLanguage 为language类.
namespace person
{
class student
{
public string name { get; set; }
public string age { get; set; }
public language speakLanguage { get; set; }
public string ex { get; set; }
}
class language
{
public string english { get; set; }
public string chinese { get; set; }
public string germany { get; set; }
}
}
student std= new student();
std.name = "tina";
std.age = "100";
std.ex = "man";
std.speakLanguage = new language();
std.speakLanguage.chinese = "yes";
std.speakLanguage.english = "yes";
std.speakLanguage.germany = "no";
{
object[] row = new object[std.GetType().GetProperties().Length];
foreach (PropertyInfo property in std.GetType().GetProperties())
{
if (property.PropertyType != typeof(String)) {
PropertyInfo[] pro=property.PropertyType.GetProperties();
foreach (PropertyInfo subproperty in pro)
{
object str&n