Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Contains with empty string
Message
De
19/07/2014 02:02:24
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01604011
Message ID:
01604151
Vues:
42
Code for .Contains() is simply:
public bool Contains( string value ) {
            return ( IndexOf(value, StringComparison.Ordinal) >=0 );
        }
so it's just a convenience method

>My thinking was the .Contains() is faster. This is simply based on my extensive VFP experience (bg). In VFP string manipulations are very fast. And the .IndexOf() "looks" like it would have to build an array first and then apply it. But I am probably "overthinking" it :)
>Thank you.
>
>>Now that Craig's reminded me I'd use .IndexOf() - at least for your specific need. :-}
>>>If it were up to you, would you use .Contains() or .IndexOf()?
>>>
>>>>Another way is variable.IndexOf("substring"). It will return -1 if it doesn't exist
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform