C# equivalent to VB instr functin

B

Brad Markisohn

Is there a C# equivalent to VB's instr function to determine if the contents
of one string are present in another?

Brad
 
J

Jim Hughes

Use the IndexOf method of the String class

String str = "longstring";
Int32 i = str.IndexOf("string");

In this case, i = 4.
 
B

Brad Markisohn

Thanks. That's just what I needed.

Brad

Jim Hughes said:
Use the IndexOf method of the String class

String str = "longstring";
Int32 i = str.IndexOf("string");

In this case, i = 4.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top