using System.Collections.Generic;
public static void Main()
Schedule s = new Schedule();
Type t = Type.GetType("Lecture");
object obj = Activator.CreateInstance(t);
obj.GetType().GetProperty("Name").SetValue(obj, "Math");
obj.GetType().GetProperty("Credit").SetValue(obj, 1);
PropertyInfo pi = s.GetType().GetProperty("LectureList");
var addMethod = pi.PropertyType.GetMethod("Add");
var lectureList = pi.GetValue(s);
addMethod.Invoke(lectureList, new object[] { obj });
Console.WriteLine(s.LectureList.Count);
public Schedule() { Name = ""; StartDate = DateTime.MinValue; LectureList = new List<Lecture>(); }
public string Name { get; set; }
public DateTime StartDate { get; set; }
public List<Lecture> LectureList { get; set; }
public string Name { get; set; }
public int Credit { get; set; }