C# equivalent to VB instr functin

  • Thread starter Thread starter Brad Markisohn
  • Start date Start date
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
 
Use the IndexOf method of the String class

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

In this case, i = 4.
 
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.
 
Back
Top