S
Shukri Adams
I'm getting a weird error with IndexOf. It only occurs if
the substring length is 1.
"aaa".IndexOf("a")
for example should return 0 , ie, it should find the
first "a" in "aaa". Instead, it return 2, the last "a".
This error does not occur in
"aaaa".IndexOf("aa")
however. Here you get the expected result of 0. In other
words, it only occurs when the substring length is 1.
But, there's more.
"aaa".IndexOf(Convert.ToChar("a"))
DOES return 0. So, the behaviour is fine for the overload
that handles chars, but not strings.
Is what I'm seeing here a bug, or is it something normal
and I'm just being clueless about the use of indexOf ?
thanks in advance
btw - I am running on .Net framework 1.1.
the substring length is 1.
"aaa".IndexOf("a")
for example should return 0 , ie, it should find the
first "a" in "aaa". Instead, it return 2, the last "a".
This error does not occur in
"aaaa".IndexOf("aa")
however. Here you get the expected result of 0. In other
words, it only occurs when the substring length is 1.
But, there's more.
"aaa".IndexOf(Convert.ToChar("a"))
DOES return 0. So, the behaviour is fine for the overload
that handles chars, but not strings.
Is what I'm seeing here a bug, or is it something normal
and I'm just being clueless about the use of indexOf ?
thanks in advance
btw - I am running on .Net framework 1.1.