c# - BindingList with IList DataSource, Element Order -


Can I assume that IList & lt; T & gt; The sequence of elements remains the same, when I use it as a

DataSource of a (Windows form) so that BindingSource.Position and List.IndexOf () Object equals at the same?

This is important to me, because Find is not supported on those lists, which are not BindingList , so I'm plain old one IList.IndexOf to determine the state of the element:

  myBindingSource.Position = myItemList.IndexOf (myItem); Apparently this works fine but I do not know if I can not really understand what I can really work on it. I'm a little worried, because  copy of property  of  listing  in new list structures (see note) ...  

Cheers, Matthias

Yes, IList & lt; T & gt; Keep the same order all the time. This is IEnumerable & lt; T & gt; (in the context of additional functionality) is a step ahead that does not guarantee to order, only the ability to calculate on the collection. IList & lt; T & gt; Add indexing to support more functionality such as . Indexoff () and . RemovalAt () for which indexing is required.

Now, regardless of the data source from your ILIT and LT; T & A; populate, return items in the same order, this is another story.

Comments