C# equilivant of instr()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the equilivant of the VB instr() function? I want to test to see if a string contains a specific character. Code samples would be appreciated. Is there a tutorial on string maniputation using C# in ASP.net ?
Thanks,
Jim
 
See String::IndexOf

--
Mike J. Deakins
For the shining star in my skies.

Jim said:
What is the equilivant of the VB instr() function? I want to test to see
if a string contains a specific character. Code samples would be
appreciated. Is there a tutorial on string maniputation using C# in ASP.net
?
 
Hi Jim,

I just had a quick look. You can use the function:
public int IndexOf(
string value,
int startIndex
);

Example:
String str = "hallo world"
int pos = str.IndexOf("wo",0)

* The result would then be 7

Hope the helps

Cheers

Gerhard


Jim said:
What is the equilivant of the VB instr() function? I want to test to see
if a string contains a specific character. Code samples would be
appreciated. Is there a tutorial on string maniputation using C# in ASP.net
?
 
Jim said:
What is the equilivant of the VB instr() function? I want to test to
see if a string contains a specific character. Code samples would be
appreciated. Is there a tutorial on string maniputation using C# in
ASP.net ?

The fact that you're using it in ASP.NET is irrelevant - it's just
normal C#/.NET string handling. I believe what you're after here is
String.IndexOf(Char) which will return -1 if the character isn't in the
string.
 
Back
Top