I only see one place where you make a string comparison, in your for loop.
I don’t use C# personally, so my first question is this: Can you use the == operator to compare strings?
You might have to use the String.Equals() method.
Either way, I think your code will throw an Exception before it can possibly return false.
I read your code like this:
If sRecherche is a substring of meubleNameToTest, set bOK to true and break out of the loop forever. Return "true".
If sRecherche is NOT a substring of meubleNameToTest, your code will throw an IndexOutOfRange exception (or something like that). It can't ever determine that rRecherche is NOT in meubleNameToTest, because it will always throw an exception before it gets to the end of the loop.
What will happen when sRecherche is not found in meubleNameToTest?? If we assume that meubleNameToTest is ten characters long and sRecherche is 3 characters long, you will run into trouble when indexLetter is greater than 7! (String.Substring will be asked to return characters 8, 9, and 10 and ten is out of range!)
Maybe this is the cause of your problem.
Long story short, you should change your for loop to this:
int patternLen = sRecherche.Length;
int loopMax = meubleStringToTest.Length - patternLen;
for ( int i = 0; i < loopMax; i ++ ) {
string searchString = meubleStringToTest.Substring(i, patternLen);
/* nous l'avons trouvé! */
if ( loopMax.Equals(searchString) ) {
return "true";
}
}
/* pas trouvé */
return "false";
Note: I've changed the names of your variables to conform to .Net naming conventions.
Otherwise Unity Answers goes berzerk trying to parse all the underscores! Also, it’s much easier to read code if you use its naming conventions. Your variable names would be great in a php program, but they’re hard on my eyes here.