Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Searching into a collection
Message
From
06/08/2006 12:43:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/08/2006 18:12:15
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01143267
Message ID:
01143304
Views:
7
>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.aspx
http://msdn2.microsoft.com/en-us/library/ms132407.aspx
http://msdn2.microsoft.com/en-us/library/ms132410.aspx

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform