Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB.NET like equivalent 1

Status
Not open for further replies.

s2001

Programmer
Dec 7, 2001
132
US
C# does not have VB.NET 'like' equivalent

For example in VB.NET, we can do this:

Dim mystr as string = "helloworld"
If mystr Like "*rld" Then
found = True
else
found =false
End If

What would be the best way to do it in C#?

Any help would be highly appreciated.



Thanks,
MB
 
string mystr = "Hello World";

if (mystr.Contains("rld"))
{
//Do Something
}

The other option is to use a RegEx (Regular Expression) if you want to do more complex searches. At that point you need to run the Match() method of a regex.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top