I have IEnumerable collection. I want to create such method:
public IEnumerable<object> Try_Filter(IEnumerable<object> collection, string property_name, string value)
{
//If object has property with name property_name,
// return collection.Where(c => c.Property_name == value)
}
Is it possible? I’m using C# 4.0.
Thanks!
Try this:
Tested with:
Although, this will be very slow for large collections