Rana
Rana

Reputation: 4611

string .IndexOf with startIndex

when you use a startIndex in a IndoexOf method if not match is found does it return -1 or your startIndex? I ran this in my code and want to make sure what I got is right.

Upvotes: 0

Views: 902

Answers (2)

Steve Danner
Steve Danner

Reputation: 22148

It will return -1 just like in the other overload of IndexOf. A quick way to find answers to things like this is a great little app called LinqPad, which allows you to write and run little snippets of code on the fly.

Upvotes: 0

driis
driis

Reputation: 164281

It returns -1 if no match is found. It clearly says so in the docs.

Upvotes: 5

Related Questions