Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Contains with empty string
Message
 
 
À
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:
01604171
Vues:
42
Interesting. Thank you.

>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
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform