Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Contains with empty string
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Using Contains with empty string
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:
01604011
Vues:
50
Hi,

I need to check if a string is within another string. Here is an example:
 if (!LongString.Contains(ShortString))
    {
           // do something
    }
The problem I have is when the short string (ShortString) is empty (""), "do something" never does anything. Of course I can get around the problem by adding to the IF ShortString.Length = 0 || . But I was wondering, can I change the .Contains somehow to make it work with empty string?

TIA
"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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform