Developing a page with asp.net (vb) and I am getting an error using an .IndexOfAny when I use a string but when just characters it works fine
My code is:
VB Code:
Dim sPhrase as String Dim sList() as String = {" AND ", "OR"} sPhrase = "John AND Mary" lblPhrase.Text = sPhrase If sPhrase.IndexOfAny(sList) = 0 Then lblResult.Text = "Not Found" Else lblResult.Text = "Found" End If
The following gives the following error:
BC30332: Value of type '1-dimensional array of String' cannot be converted to '1-dimensional array of Char' because 'String' is not derived from 'Char'.
If I change the following line:
Dim sList() as String = {" AND ", "OR"}
to
Dim sList() as Char = {"a", "e"}
Things seem to work fine. Is it not possible to search and array of strings with the IndexOfAny?
Thanks.




Reply With Quote