Generation

generate functionSat, 12 Nov 2022

get property under an object without knowing name

public dynamic GetPropByName(dynamic obj, string propName) { // Type type = obj.GetType(); // PropertyInfo pInfo = type.GetProperty(propName); // return pInfo.GetValue(obj, null); return obj.GetType().GetProperty(propName).GetValue(obj, null); }

Questions about programming?Chat with your personal AI assistant