Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Contains with empty string
Message
 
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01604011
Message ID:
01604171
Views:
41
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
Previous
Reply
Map
View

Click here to load this message in the networking platform