471,066 Members | 1,288 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

How to find string in C#

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
Nov 15 '05 #1
3 11570
Check the IndexOf method.

HTH;
Eric Cadwell
http://www.origincontrols.com
Nov 15 '05 #2
Peter Afonin <pa**@specialtypulltabs.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Thank you everybody, I'll try!

Peter

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Peter Afonin <pa**@specialtypulltabs.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by hokieghal99 | last post: by
8 posts views Thread by Jaime Wyant | last post: by
3 posts views Thread by Chris Mantoulidis | last post: by
3 posts views Thread by Prakash Bande | last post: by
108 posts views Thread by Bryan Olson | last post: by
4 posts views Thread by KL | last post: by
7 posts views Thread by tehn.yit.chin | last post: by
14 posts views Thread by micklee74 | last post: by
11 posts views Thread by Ko van der Sloot | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.