📜  将任何类转换为键值对 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:29.928000             🧑  作者: Mango

代码示例1
[Test]
public void DoStuff() {
  List things = new List() {
    new ResultA(){Date = DateTime.Now, Month = 34}, new ResultB(){Count = 1, Jewels = 4, Number = "2", Update = "0"}
  };

  foreach (var thing in things) {
    foreach (var property in thing.GetType().GetProperties()) {
      Trace.WriteLine(property.Name + " " + property.GetValue(thing));
    }
  }
}