c# – How to iterate through classes fields and set properties
Here’s a complete working example: public class Person { public string Name { get; set; } } class Program { static void PropertySet(object p, string propName, object value) { Type t = p.GetType(); PropertyInfo info = t.GetProperty(propName); if (info == null) return; if (!info.CanWrite) return; info.SetValue(p, value, null); } static void PropertySetLooping(object p, string propName, … Read more