Why doesn’t BindingList(Of T).Add return index

Why doesn’t BindingList(Of T).Add return index

Old forum URL: forums.lhotka.net/forums/t/1349.aspx


Henrik posted on Wednesday, September 27, 2006

Now why is it that BindingList(Of T).Add method doesn’t return the index of the newly added item?

 

I’m in a situation where I need a very fast lookup of readonly SystemAccount info objects.

I’ve build a ReadOnlyList that loads the entire list of SystemAccountInfo objects on first hit (around 4000 of them).

I need to look each SystemAccountInfo up on the sub-domain, that a user is entering the site with. To do this fast enough, I’ve implemented a lookup table, in the ReadOnlyList, as a Dictionary(Of String, Integer) where I will store the subdomain as the key and the index of the SystemAccountInfo in the ReadOnlyList as value.

However, I presumed that I could get the index from the Add method, so I won’t have to call IndexOf, which I  assume can have a complexity of O(N).

Am I right about that and is there a fast way I can get the index of the newly added item?

 

Thanks in advance

/Henrik

Henrik replied on Wednesday, September 27, 2006

Ahh stupid me, I should just use the Insert method instead.

/Henrik

Copyright (c) Marimer LLC