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); }

Want to kickstart your project?Use the new AI Studio to create your code