0

Is it possible to search for a term within a string and output the result either 1 (True) or 0 (false)?

e.g;

string str = 1234567890

if (str.contains = "456")
{
    MessageBox.Show("True!")
}
else
{
    MessageBox.Show("False!")
}

I know I can search for individual chars but I want to be able to match a string and so I don't get a false positive.

thanks in advance!

Edited by buster2209: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by buster2209
0

The "Contains" method might be what you're looking for:

string str = "1234567890";

if (str.Contains("456"))
{
    MessageBox.Show("True!");
}
else
{
    MessageBox.Show("False!");
}

Edited by GuitarComet: n/a

0

LOL!

Yup, my pseudo code was almost the same syntax as C#.....

Thanks!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.