SetProperty and GetProperty with C# Reflection

SetProperty and GetProperty with C# Reflection

 

private object getProperty(object containingObject, string propertyName) {

return containingObject.GetType().InvokeMember(propertyName, BindingFlags.GetProperty, null, containingObject, null);

}

private void setProperty(object containingObject, string propertyName, object newValue)
{

containingObject.GetType().InvokeMember(propertyName, BindingFlags.SetProperty, null, containingObject, new object[] { newValue });

}

Comments

Popular posts from this blog

To Move items from one ListBox to another Listbox

Receive Json Web response in C#