This is a migrated thread and some comments may be shown as answers.

How function IndexOf works in DataItemCollecion

1 Answer 41 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mariusz
Top achievements
Rank 1
Mariusz asked on 15 Sep 2011, 01:01 PM
Is function IndexOf in DataItemCollecion using Equals method on objects?

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 20 Sep 2011, 11:49 AM
Hello Mariusz,

Generally DataItemCollection.IndexOf(item) works as IList.IndexOf() method, which in fact uses BO.Equals method. Due to some optimization when RadGridView is sorted DataItemCollection.IndexOf(item) uses Dictionary.TryGetValue method which also relies on BO.GetHashCode() method. By the way according to this msdn article you should also override GetHashCode(), so in any case IndexOf() will work correctly.
Let me know if this doesn't help.

Best wishes,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Mariusz
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or