TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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?
Reply
Answers (
3
)
How to retrieve a list of items from listbox in C#
ArrayList