How to find string in C#

  • Thread starter Thread starter Peter Afonin
  • Start date Start date
P

Peter Afonin

Hello:

In VB I was using InStr function to determice whether some string exists
within another string. How would I do it in C#?

For instance, I have a long string created by StringBuilder. I need to find
out if this string contains the words "Not found". Is there a C# function
for it? or perhaps I could use wildcards? Or can I use StringBuilder for
this?

I would appreciate your help.

Thank you,
 
Peter Afonin said:
In VB I was using InStr function to determice whether some string exists
within another string. How would I do it in C#?

Use String.IndexOf, and compare the result with -1.
 
Back
Top