I have an indexer method inside a class that allows me to do this:
var foo = Class["bar"];
Class["bar"] = foo;
Here it is:
public object this[string propertyName]
{
get { return this.GetType().GetProperty(propertyName).GetValue(this, null); }
set { this.GetType().GetProperty(propertyName).SetValue(this, value, null); }
}
I want to get an array of PropertyInfo[] and loop through it to get the values of the properties. But this extension method (type System.Object) is making its way in the array and I don't know how to exclude it.
I could exclude it inside my loop. But it could be problematic if my class does contain an "Item" property. Any ideas?
PropertyInfo[] properties = typeof(Class).GetProperties();
foreach(var prop in properties)
if(prop.name == "Item")
continue;