>When my collection only contains a string, I think it should be pretty much straight forward when searching for an item in it. For example, to search for a string in a collection, I have to do this:
>
>
> Dim lcCache As String = ""
> Dim lcCacheItem As String = ""
> Dim llExist As Boolean = False
> Dim loCache As Collection = New Collection
>
> For Each lcCacheItem In loCache
> If lcCacheItem = lcCache Then
> llExist = True
> End If
> Next
>
>
>Isn't there a way to achieve that by using the collection's own method such as:
>
>
> Dim lcCache As String = ""
> Dim llExist As Boolean = False
> Dim loCache As Collection = New Collection
>
> llExist=loCache.IsMyItemExist(lcCache)
>
Michel,
Use generic version IMHO. You can use Contains or IndexOf (-1 if do not exist):
http://msdn2.microsoft.com/en-us/library/ms132398.aspxhttp://msdn2.microsoft.com/en-us/library/ms132407.aspxhttp://msdn2.microsoft.com/en-us/library/ms132410.aspxCetin