manK

manK

  • NA
  • 3
  • 0

Filtering a collectiion

Sep 3 2007 12:35 AM
Hi I am using the following code to filter entries. public CollectionEx Filter(CollectionEx pList, String pPropertyName, object pFilterValue) { CollectionEx filteredList = new CollectionEx(); foreach (T item in pList) { Type itemType = item.GetType(); PropertyInfo propertyInfo = item.GetType().GetProperty(pPropertyName); object valueOfX = propertyInfo.GetValue(item, null); if (valueOfX == pFilterValue) { filteredList.Add(item); } } return filteredList; } Even in situations where the objects are equal, this statement always evaluates to false. if (valueOfX == pFilterValue) Where am i going wrong?

Answers (3)