Answers for "Convert any class to a keyvaluepair"

0

Convert any class to a keyvaluepair

[Test]
public void DoStuff() {
  List<object> things = new List<object>() {
    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));
    }
  }
}
Posted by: Guest on March-19-2021

Code answers related to "Convert any class to a keyvaluepair"

Browse Popular Code Answers by Language