Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Searching into a collection
Message
De
06/08/2006 12:43:56
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/08/2006 18:12:15
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01143267
Message ID:
01143304
Vues:
8
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform