string problem

  • Thread starter Thread starter Rosario
  • Start date Start date
R

Rosario

Hi at all,
I hope that someone can help me.
I have two string A="abcxxxdef "and B="xxx" and I would
want to know if into the A string exist one or more
occurrences of B string. In this case would serve me a
function that, taken in input the two strings, gives back
1 to me. It exists? or is something much similar one?
However thanks.
 
You can use String.IndexOf(String).

Hi at all,
I hope that someone can help me.
I have two string A="abcxxxdef "and B="xxx" and I would
want to know if into the A string exist one or more
occurrences of B string. In this case would serve me a
function that, taken in input the two strings, gives back
1 to me. It exists? or is something much similar one?
However thanks.
 
What you need is the IndexOf() method:

string A = "abcxxxdef";
string B = "xxx";

Console.WriteLine(A.IndexOf(B));

will produce "3".
 
Back
Top