请参阅下面的代码,有人可以帮助我....
public class person
{
Public string name { get; set; };
Public personDetails Pdetails { get; };
}
public class personDetails
{
Public bool hasChild { get; set; }
Public string ChildName { get; set; }
}
static void Main(string[] args)
{
Type type = asm.GetType(person);
object classInstance = Activator.CreateInstance(type);
PropertyInfo prop = type.GetProperty("Pdetails ", BindingFlags.Public | BindingFlags.Instance);
if (null != prop && prop.CanWrite)
{
prop.SetValue(classInstance, null , null);
}
}
找不到属性的错误。