Say I have a big char array with several thousand items:
char[] mobyDick = "..."
such that mobyDick.Length
= 2000.
I want to find out if a certain array of characters exists in that array in that order, and where* it is. (Update: I really just need to know if it's after a certain index in the main array.)
char[] test = {'a','b','c','d'}
I could do something like
char[] mobyDick = "..."
string mobyString = new string(mobyDick);
if (mobyString.Contains(new string(test)))
{ do stuff}
but that's not optimal for my situation, since I'm trying to write a parser that would have to work very quickly, and I don't want to have to be creating and searching strings every letter or so.
Is there some way (algorithmically or via some .Net method) to find out whether mobyDick
as a char array contains abcd
as a char array?